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 9CLANGFORMATDIFF=`git config --get clangformatdiff.binary` 10 11if [ -z "$CLANGFORMATDIFF" ]; then 12 CLANGFORMATDIFF=clang-format-diff.py 13fi 14 15errors=`git diff-index --cached --diff-filter=ACMR -p HEAD lib src examples tests | $CLANGFORMATDIFF -p1` 16 17if [ -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 27fi 28