File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 18
18
# If you want to allow non-ascii filenames set this variable to true.
19
19
allownonascii=$( git config hooks.allownonascii)
20
20
21
+ # Redirect output to stderr.
22
+ exec 1>&2
23
+
21
24
# Cross platform projects tend to avoid non-ascii filenames; prevent
22
25
# them from being added to the repository. We exploit the fact that the
23
26
# printable range starts at the space character and ends with tilde.
24
27
if [ " $allownonascii " != " true" ] &&
25
28
# Note that the use of brackets around a tr range is ok here, (it's
26
29
# even required, for portability to Solaris 10's /usr/bin/tr), since
27
30
# the square bracket bytes happen to fall in the designated range.
28
- test " $( git diff --cached --name-only --diff-filter=A -z $against |
29
- LC_ALL=C tr -d ' [ -~]\0' ) "
31
+ test $( git diff --cached --name-only --diff-filter=A -z $against |
32
+ LC_ALL=C tr -d ' [ -~]\0' | wc -c ) ! = 0
30
33
then
31
34
echo " Error: Attempt to add a non-ascii file name."
32
35
echo
43
46
exit 1
44
47
fi
45
48
49
+ # If there are whitespace errors, print the offending file names and fail.
46
50
exec git diff-index --check --cached $against --
You can’t perform that action at this time.
0 commit comments