diff --git a/scripts/reindent.sh b/scripts/reindent.sh index 12e34ea..2dc67af 100755 --- a/scripts/reindent.sh +++ b/scripts/reindent.sh @@ -68,10 +68,19 @@ fi tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT INT TERM +# Accept both repo-relative and absolute paths: the default file list is +# relative, but callers (including the pre-commit hook) pass absolute ones. +abspath() { + case "$1" in + /*) printf '%s' "$1" ;; + *) printf '%s/%s' "$root" "$1" ;; + esac +} + copies='' for f in $files; do dest="$tmp/$(printf '%s' "$f" | tr '/' '_')" - cp "$root/$f" "$dest" + cp "$(abspath "$f")" "$dest" copies="$copies $dest" done @@ -84,7 +93,7 @@ emacs --batch -Q -l "$elisp" -- $copies >/dev/null || { status=0 for f in $files; do dest="$tmp/$(printf '%s' "$f" | tr '/' '_')" - if ! cmp -s "$root/$f" "$dest"; then + if ! cmp -s "$(abspath "$f")" "$dest"; then echo "$f" status=1 fi