summaryrefslogtreecommitdiff
path: root/tools/pre-commit
blob: 62469e1530d6c57a7ea60dc2e30ab633559d5ca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# Copyright 2013, Alexis La Goutte (See AUTHORS file)
#
# For git user, copy pre-commit in .git/hook/ folder
#   to don't launch the script when commit use --no-verify argument
#
# From
# http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes
#

if [ -z $GIT_DIR ]; then GIT_DIR=".git"; fi
# Check for newer versions of the pre-commit script
if [ ${GIT_DIR}/hooks/pre-commit -ot ./tools/pre-commit ] ; then
    echo "Pre-commit hook script is outdated, please update!"
fi

for FILE in `git diff-index --cached --name-only HEAD | grep "\.[ch]$"` ; do
    #Exit immediately if a command exits with a non-zero status.
    set -e

    #Check if checkhf is good
    ./tools/checkhf.pl $FILE

    #Check if checkAPIs is good
    ./tools/checkAPIs.pl -p $FILE

    #Check if fix-encoding-args is good
    ./tools/fix-encoding-args.pl $FILE

done

# If there are whitespace errors, print the offending file names and fail. (from git pre-commit.sample)
exec git diff-index --check --cached HEAD

exit

#
#  Editor modelines
#
#  Local Variables:
#  c-basic-offset: 4
#  tab-width: 8
#  indent-tabs-mode: nil
#  End:
#
#  ex: set shiftwidth=4 tabstop=8 expandtab:
#  :indentSize=4:tabSize=8:noTabs=true:
#