Add check of whitespace error after Wireshark check (checkhf, checAPIs...)
[metze/wireshark/wip.git] / tools / pre-commit
1 #!/bin/sh
2 # Copyright 2013, Alexis La Goutte (See AUTHORS file)
3 #
4 # For git user, copy pre-commit in .git/hook/ folder
5 #   to don't launch the script when commit use --no-verify argument
6 #
7 # From
8 # http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes
9 #
10
11 # Check for newer versions of the pre-commit script
12 if [ ./.git/hooks/pre-commit -ot ./tools/pre-commit ] ; then
13     echo "Pre-commit hook script is outdated, please update!"
14 fi
15
16 for FILE in `git diff-index --cached --name-only HEAD | grep "\.[ch]$"` ; do
17     #Exit immediately if a command exits with a non-zero status.
18     set -e
19
20     #Check if checkhf is good
21     ./tools/checkhf.pl $FILE
22
23     #Check if checkAPIs is good
24     ./tools/checkAPIs.pl $FILE
25
26     #Check if fix-encoding-args is good
27     ./tools/fix-encoding-args.pl $FILE
28
29     #Check if fix-encoding-args is good
30     ./tools/fix-encoding-args.pl $FILE
31
32 done
33
34 # If there are whitespace errors, print the offending file names and fail. (from git pre-commit.sample)
35 exec git diff-index --check --cached HEAD
36
37 exit
38
39 #
40 #  Editor modelines
41 #
42 #  Local Variables:
43 #  c-basic-offset: 4
44 #  tab-width: 8
45 #  indent-tabs-mode: nil
46 #  End:
47 #
48 #  ex: set shiftwidth=4 tabstop=8 expandtab:
49 #  :indentSize=4:tabSize=8:noTabs=true:
50 #