annotate graster/graster/.git/hooks/pre-commit.sample @ 11:f952052e37b7

trying a fix.
author Robert McIntyre <rlm@mit.edu>
date Tue, 24 Aug 2010 19:06:45 -0400
parents
children
rev   line source
rlm@11 1 #!/bin/sh
rlm@11 2 #
rlm@11 3 # An example hook script to verify what is about to be committed.
rlm@11 4 # Called by git-commit with no arguments. The hook should
rlm@11 5 # exit with non-zero status after issuing an appropriate message if
rlm@11 6 # it wants to stop the commit.
rlm@11 7 #
rlm@11 8 # To enable this hook, rename this file to "pre-commit".
rlm@11 9
rlm@11 10 if git-rev-parse --verify HEAD >/dev/null 2>&1
rlm@11 11 then
rlm@11 12 against=HEAD
rlm@11 13 else
rlm@11 14 # Initial commit: diff against an empty tree object
rlm@11 15 against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
rlm@11 16 fi
rlm@11 17
rlm@11 18 # If you want to allow non-ascii filenames set this variable to true.
rlm@11 19 allownonascii=$(git config hooks.allownonascii)
rlm@11 20
rlm@11 21 # Cross platform projects tend to avoid non-ascii filenames; prevent
rlm@11 22 # them from being added to the repository. We exploit the fact that the
rlm@11 23 # printable range starts at the space character and ends with tilde.
rlm@11 24 if [ "$allownonascii" != "true" ] &&
rlm@11 25 # Note that the use of brackets around a tr range is ok here, (it's
rlm@11 26 # even required, for portability to Solaris 10's /usr/bin/tr), since
rlm@11 27 # the square bracket bytes happen to fall in the designated range.
rlm@11 28 test "$(git diff --cached --name-only --diff-filter=A -z $against |
rlm@11 29 LC_ALL=C tr -d '[ -~]\0')"
rlm@11 30 then
rlm@11 31 echo "Error: Attempt to add a non-ascii file name."
rlm@11 32 echo
rlm@11 33 echo "This can cause problems if you want to work"
rlm@11 34 echo "with people on other platforms."
rlm@11 35 echo
rlm@11 36 echo "To be portable it is advisable to rename the file ..."
rlm@11 37 echo
rlm@11 38 echo "If you know what you are doing you can disable this"
rlm@11 39 echo "check using:"
rlm@11 40 echo
rlm@11 41 echo " git config hooks.allownonascii true"
rlm@11 42 echo
rlm@11 43 exit 1
rlm@11 44 fi
rlm@11 45
rlm@11 46 exec git diff-index --check --cached $against --