aboutsummaryrefslogtreecommitdiff
path: root/contrib/uncrustify_precommit
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/uncrustify_precommit')
-rwxr-xr-xcontrib/uncrustify_precommit35
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit
new file mode 100755
index 00000000..fd29998c
--- /dev/null
+++ b/contrib/uncrustify_precommit
@@ -0,0 +1,35 @@
1#!/bin/sh
2
3# use as .git/hooks/pre-commit
4
5exec 1>&2
6
7RET=0
8changed=$(git diff --cached --name-only)
9crustified=""
10
11for f in $changed;
12do
13 if echo $f | grep \\.[c,h]\$ > /dev/null
14 then
15 # compare result of uncrustify with changes
16 #
17 # only change any of the invocations here if
18 # they are portable across all cmp and shell
19 # implementations !
20 uncrustify -q -c uncrustify.cfg -f $f | cmp -s $f -
21 if test $? = 1 ;
22 then
23 crustified=" $crustified $f"
24 RET=1
25 fi
26 fi
27done
28
29if [ $RET = 1 ];
30then
31 echo "Run"
32 echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}"
33 echo "before commiting."
34fi
35exit $RET