my customized lib

Committer:
DuyLionTran
Date:
Sun Nov 26 15:08:14 2017 +0000
Revision:
0:8094b249013c
Initial commit

Who changed what in which revision?

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