aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 14:55:12 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 14:55:12 +0200
commitcf4cfd3f99412dc15be66cc67cbda221141c4594 (patch)
tree5c726c20e8735ac2d922fc04cdafaebe54000f59
parent8c52967c1ca5eff4aeb6e4452b8958b73240b133 (diff)
downloadgnunet-cf4cfd3f99412dc15be66cc67cbda221141c4594.tar.gz
gnunet-cf4cfd3f99412dc15be66cc67cbda221141c4594.zip
fix hook to only apply to C code
-rw-r--r--contrib/uncrustify_precommit29
1 files changed, 15 insertions, 14 deletions
diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit
index bf7bac4ef..a370277cc 100644
--- a/contrib/uncrustify_precommit
+++ b/contrib/uncrustify_precommit
@@ -5,30 +5,31 @@
5exec 1>&2 5exec 1>&2
6 6
7RET=0 7RET=0
8
9changed=$(git diff --cached --name-only) 8changed=$(git diff --cached --name-only)
10crustified="" 9crustified=""
11 10
12for f in $changed; 11for f in $changed;
13do 12do
14 # compare result of uncrustify with changes 13 # compare result of uncrustify with changes
15 # 14 #
16 # only change any of the invocations here if 15 # only change any of the invocations here if
17 # they are portable across all cmp and shell 16 # they are portable across all cmp and shell
18 # implementations! 17 # implementations !
19 uncrustify -q -c uncrustify.cfg -f $f | cmp -s $f - 18 uncrustify - q - c uncrustify.cfg - f $f | cmp - s $f -
20 if test $? = 1 ; 19 if test $? = 1 ;
21 then 20 then
21 if echo $f | grep \\.[c,h]\$ > /dev/null
22 then
22 crustified=" $crustified $f" 23 crustified=" $crustified $f"
23 RET=1 24 RET=1
24 fi 25 fi
26 fi
25done 27done
26 28
27if [ $RET = 1 ]; 29if [ $RET = 1 ];
28then 30then
29 echo "Run" 31 echo "Run"
30 echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}" 32 echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}"
31 echo "before commiting." 33 echo "before commiting."
32fi 34fi
33
34exit $RET 35exit $RET