3 # Called by "git commit" with no arguments. The hook should
4 # exit with non-zero status after issuing an appropriate message if
5 # it wants to stop the commit.
7 # To enable this hook, copy this file into ~/.git/hooks and make it executable
9 if git rev-parse --verify HEAD >/dev/null 2>&1
13 # Initial commit: diff against an empty tree object
14 against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
17 files=`git diff-index --name-only --cached $against`
22 if test `echo $f | egrep -c "\.([ch]|cc)$"` -gt 0 ; then
27 # Redirect output to stderr.
30 #-------------------------------------------------------------------------------
31 # Check the copyright notice of all files to be commited.
33 user=`git config --global user.email`
36 missing_copyright_year=""
38 if test ! -f $f ; then
39 # If file does not exist, it was probably part of a rename or something.
41 elif test `head -5 $f | grep -c -i copyright` -eq 0 ; then
42 missing_copyright="$missing_copyright $f"
46 if test -n "$missing_copyright" ; then
47 echo "Missing the copyright notice of the following files:"
48 for f in $missing_copyright ; do
51 echo "Commit aborted."
55 #-------------------------------------------------------------------------------
56 # Check the formatting of all C/C++ files.
58 if test -n "$cfiles" ; then
59 tools/cstyle.py $cfiles
60 if test $? -ne 0 ; then
62 echo "Commit aborted. Fix the above error before trying again."