chiark / gitweb /
pre-commit: fix multiple file issue
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 15 Feb 2016 12:01:43 +0000 (12:01 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 15 Feb 2016 12:04:34 +0000 (12:04 +0000)
When using -z, you should always quote. If not, stuff like this happens:

.git/hooks/pre-commit: line 10: [: too many arguments

hooks/pre-commit

index 6dd0049d5ee3ae7ffc832b54fd90cc0a679aaf9e..5ac72c1cb6a55d28de440a7052671204cb59d6cf 100755 (executable)
@@ -7,7 +7,7 @@
 exec 1>&2
 
 files=`git diff-index --cached HEAD 2>&1 | sed 's/^:.*     //' | uniq | cut -b100-500`
-if [ -z $files ]; then
+if [ -z "$files" ]; then
     PY_FILES="fdroid makebuildserver setup.py examples/*.py buildserver/*.py fdroidserver/*.py"
     PY_TEST_FILES="tests/*.TestCase"
     SH_FILES="hooks/pre-commit"