annotate BSseeker2/.git/hooks/pre-commit.sample @ 1:8b26adf64adc draft default tip

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