tizen 2.4 release
[external/nghttp2.git] / pre-commit
1 #!/bin/sh -e
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
9 CLANGFORMATDIFF=`git config --get clangformatdiff.binary`
10
11 if [ -z "$CLANGFORMATDIFF" ]; then
12     CLANGFORMATDIFF=clang-format-diff.py
13 fi
14
15 errors=`git diff-index --cached --diff-filter=ACMR -p HEAD -- | $CLANGFORMATDIFF -p1`
16
17 if [ -n "$errors" ]; then
18     echo "$errors"
19     echo "--"
20     echo "[ERROR] We have detected the difference between the code to commit"
21     echo "and clang-format style rules.  Please fix this problem in either:"
22     echo "1) Apply patch above."
23     echo "2) Use clang-format to format lines."
24     echo "3) Reformat these lines manually."
25     echo "Aborting commit."
26     exit 1
27 fi