Debian Codegraph @

scripts/pre-commit.sample

raw
1 #!/bin/sh
2
3 gitclangformat=$(which git-clang-format)
4
5 if [ "$gitclangformat" == "" ]
6 then
7 gitclangformat=$(find /usr/bin/ -name "git-clang-format*")
8 fi
9
10 against=`git rev-parse --verify HEAD 2>&1`
11
12 if [ $against == "" ]
13 then
14 # Initial commit: diff against an empty tree object
15 against=5394c6fa5bf40d9bc8619026cbc4c306211a8499
16 fi
17
18 $gitclangformat $against -f -q
19
20 if [ $? != 0 ]
21 then
22 echo "Format error!"
23 echo "Use git clang-format"
24 exit 1
25 fi
26
27 # Now update format changes and commit
28 git add $(git diff --name-only --cached)