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.
8 # To enable this hook, rename this file to "pre-commit".
10 if git rev-parse --verify HEAD >/dev/null 2>&1
14 # Initial commit: diff against an empty tree object
15 against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
18 # If you want to allow non-ascii filenames set this variable to true.
19 allownonascii=$(git config hooks.allownonascii)
22 # Redirect output to stderr.
25 # Cross platform projects tend to avoid non-ascii filenames; prevent
26 # them from being added to the repository. We exploit the fact that the
27 # printable range starts at the space character and ends with tilde.
28 if [ "$allownonascii" != "true" ] &&
29 # Note that the use of brackets around a tr range is ok here, (it's
30 # even required, for portability to Solaris 10's /usr/bin/tr), since
31 # the square bracket bytes happen to fall in the designated range.
32 test $(git diff --cached --name-only --diff-filter=A -z $against |
33 LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
35 echo "Error: Attempt to add a non-ascii file name."
37 echo "This can cause problems if you want to work"
38 echo "with people on other platforms."
40 echo "To be portable it is advisable to rename the file ..."
42 echo "If you know what you are doing you can disable this"
45 echo " git config hooks.allownonascii true"
51 version=`astyle --version 2> /dev/null`
52 if test "x$version" != "x"; then
53 echo "SDF3 git pre-receive hook:"
54 echo "Did not find astyle, please install it before continuing."
59 case `$ASTYLE --version 2> /dev/null` in
63 echo "SDF3 git pre-commit hook:"
64 echo "Did not find astyle, please install it before continuing."
69 ASTYLE_PARAMETERS="--style=allman \
76 --indent-col1-comments \
77 --min-conditional-indent=0 \
81 --align-pointer=name \
85 # --one-line=keep-statements
86 # --indent-preprocessor
91 newfile=${file}.astyled
92 #$ASTYLE ${ASTYLE_PARAMETERS} < $file > $newfile 2>>/dev/null
93 $ASTYLE -a -f -p -o -O -c -s2 -U -x --mode=c < $file > $newfile 2>>/dev/null
94 diff "${file}" "${newfile}"
98 echo "Code style error in '$file', please fix before commiting."
99 echo "To autofix, create a hidden file named './.fix_style' on suite root."
106 echo "Source code style checking ..."
108 files=`git-diff-index --diff-filter=ACMR --name-only -r --cached $against --`
109 for file in $files; do
110 x=`echo $file |grep -E '(\.cpp|\.hpp)'`
111 if test "x$x" != "x"; then
117 # If there are whitespace errors, print the offending file names and fail.
118 #exec git diff-index --check --cached $against --