Skip to content

Commit d9fd71f

Browse files
druckdevgitster
authored andcommitted
hooks--pre-commit: detect non-ASCII when renaming
When diff.renames is turned on, the diff-filter will not return renamed files (or copied ones with diff.renames=copy) and potential non-ASCII characters would not be caught by this hook. Use the plumbing command diff-index instead of the porcelain one to not be affected by diff.rename. Signed-off-by: Julian Prein <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ec58344 commit d9fd71f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

templates/hooks--pre-commit.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if [ "$allownonascii" != "true" ] &&
2828
# Note that the use of brackets around a tr range is ok here, (it's
2929
# even required, for portability to Solaris 10's /usr/bin/tr), since
3030
# the square bracket bytes happen to fall in the designated range.
31-
test $(git diff --cached --name-only --diff-filter=A -z $against |
31+
test $(git diff-index --cached --name-only --diff-filter=A -z $against |
3232
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
3333
then
3434
cat <<\EOF

0 commit comments

Comments
 (0)