Mercurial > repos > devteam > picard_122_up
comparison .git/hooks/pre-commit.sample @ 2:801f5e934011 draft default tip
Uploaded
| author | devteam |
|---|---|
| date | Thu, 23 Oct 2014 11:40:52 -0400 |
| parents | b76a4f17bbbb |
| children |
comparison
equal
deleted
inserted
replaced
| 1:f3e98264fbdd | 2:801f5e934011 |
|---|---|
| 1 #!/bin/sh | |
| 2 # | |
| 3 # An example hook script to verify what is about to be committed. | |
| 4 # Called by "git commit" with no arguments. The hook should | |
| 5 # exit with non-zero status after issuing an appropriate message if | |
| 6 # it wants to stop the commit. | |
| 7 # | |
| 8 # To enable this hook, rename this file to "pre-commit". | |
| 9 | |
| 10 if git rev-parse --verify HEAD >/dev/null 2>&1 | |
| 11 then | |
| 12 against=HEAD | |
| 13 else | |
| 14 # Initial commit: diff against an empty tree object | |
| 15 against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
| 16 fi | |
| 17 | |
| 18 # If you want to allow non-ascii filenames set this variable to true. | |
| 19 allownonascii=$(git config hooks.allownonascii) | |
| 20 | |
| 21 # Cross platform projects tend to avoid non-ascii filenames; prevent | |
| 22 # them from being added to the repository. We exploit the fact that the | |
| 23 # printable range starts at the space character and ends with tilde. | |
| 24 if [ "$allownonascii" != "true" ] && | |
| 25 # Note that the use of brackets around a tr range is ok here, (it's | |
| 26 # even required, for portability to Solaris 10's /usr/bin/tr), since | |
| 27 # 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')" | |
| 30 then | |
| 31 echo "Error: Attempt to add a non-ascii file name." | |
| 32 echo | |
| 33 echo "This can cause problems if you want to work" | |
| 34 echo "with people on other platforms." | |
| 35 echo | |
| 36 echo "To be portable it is advisable to rename the file ..." | |
| 37 echo | |
| 38 echo "If you know what you are doing you can disable this" | |
| 39 echo "check using:" | |
| 40 echo | |
| 41 echo " git config hooks.allownonascii true" | |
| 42 echo | |
| 43 exit 1 | |
| 44 fi | |
| 45 | |
| 46 exec git diff-index --check --cached $against -- |
