Merge branch 'maint'
* maint: make the sample pre-commit hook script reject names with newlines, too
This commit is contained in:
commit
997a1946a5
@ -18,6 +18,9 @@ fi
|
|||||||
# If you want to allow non-ascii filenames set this variable to true.
|
# If you want to allow non-ascii filenames set this variable to true.
|
||||||
allownonascii=$(git config hooks.allownonascii)
|
allownonascii=$(git config hooks.allownonascii)
|
||||||
|
|
||||||
|
# Redirect output to stderr.
|
||||||
|
exec 1>&2
|
||||||
|
|
||||||
# Cross platform projects tend to avoid non-ascii filenames; prevent
|
# Cross platform projects tend to avoid non-ascii filenames; prevent
|
||||||
# them from being added to the repository. We exploit the fact that the
|
# them from being added to the repository. We exploit the fact that the
|
||||||
# printable range starts at the space character and ends with tilde.
|
# printable range starts at the space character and ends with tilde.
|
||||||
@ -25,8 +28,8 @@ if [ "$allownonascii" != "true" ] &&
|
|||||||
# Note that the use of brackets around a tr range is ok here, (it's
|
# Note that the use of brackets around a tr range is ok here, (it's
|
||||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||||
# the square bracket bytes happen to fall in the designated range.
|
# the square bracket bytes happen to fall in the designated range.
|
||||||
test "$(git diff --cached --name-only --diff-filter=A -z $against |
|
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||||
LC_ALL=C tr -d '[ -~]\0')"
|
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||||
then
|
then
|
||||||
echo "Error: Attempt to add a non-ascii file name."
|
echo "Error: Attempt to add a non-ascii file name."
|
||||||
echo
|
echo
|
||||||
@ -43,4 +46,5 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If there are whitespace errors, print the offending file names and fail.
|
||||||
exec git diff-index --check --cached $against --
|
exec git diff-index --check --cached $against --
|
||||||
|
Loading…
x
Reference in New Issue
Block a user