summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-26 23:09:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-10-26 23:09:28 (GMT)
commit411e6cf1971936ba31ffa142a6d5dc5c06dc8f7a (patch)
treef3b8758bc896acb1e557a4cd83b3167341e1d006 /templates
parent982d1dce349732539780ee81bb79c8ab26eaed20 (diff)
parent588150b0231ee342ed528292a2205f4049b3dcb1 (diff)
downloadgit-411e6cf1971936ba31ffa142a6d5dc5c06dc8f7a.zip
git-411e6cf1971936ba31ffa142a6d5dc5c06dc8f7a.tar.gz
git-411e6cf1971936ba31ffa142a6d5dc5c06dc8f7a.tar.bz2
Merge branch 'maint-1.7.6' into maint
* maint-1.7.6: make the sample pre-commit hook script reject names with newlines, too git-read-tree.txt: update sparse checkout examples git-read-tree.txt: correct sparse-checkout and skip-worktree description git-read-tree.txt: language and typography fixes unpack-trees: print "Aborting" to stderr Documentation/git-update-index: refer to 'ls-files' Documentation: basic configuration of notes.rewriteRef
Diffstat (limited to 'templates')
-rwxr-xr-xtemplates/hooks--pre-commit.sample8
1 files changed, 6 insertions, 2 deletions
diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample
index b187c4b..18c4829 100755
--- a/templates/hooks--pre-commit.sample
+++ b/templates/hooks--pre-commit.sample
@@ -18,6 +18,9 @@ fi
# If you want to allow non-ascii filenames set this variable to true.
allownonascii=$(git config hooks.allownonascii)
+# Redirect output to stderr.
+exec 1>&2
+
# Cross platform projects tend to avoid non-ascii filenames; prevent
# them from being added to the repository. We exploit the fact that the
# 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
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
- test "$(git diff --cached --name-only --diff-filter=A -z $against |
- LC_ALL=C tr -d '[ -~]\0')"
+ test $(git diff --cached --name-only --diff-filter=A -z $against |
+ LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
echo "Error: Attempt to add a non-ascii file name."
echo
@@ -43,4 +46,5 @@ then
exit 1
fi
+# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --