diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:12:11 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:12:47 +0200 |
commit | 52bbfe926be03f66d57d15743e9914bc4e201c8c (patch) | |
tree | 9e3befbd9a81d250eaeb06655ddc9ec539a561ca /contrib/uncrustify_precommit | |
parent | 041ba85c6a78621f8c639482b26b0328b21cc442 (diff) | |
download | exchange-52bbfe926be03f66d57d15743e9914bc4e201c8c.tar.xz |
add uncrustify pre-commit hook
Diffstat (limited to 'contrib/uncrustify_precommit')
-rwxr-xr-x | contrib/uncrustify_precommit | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit new file mode 100755 index 000000000..fd29998c3 --- /dev/null +++ b/contrib/uncrustify_precommit @@ -0,0 +1,35 @@ +#!/bin/sh + +# use as .git/hooks/pre-commit + +exec 1>&2 + +RET=0 +changed=$(git diff --cached --name-only) +crustified="" + +for f in $changed; +do + if echo $f | grep \\.[c,h]\$ > /dev/null + then + # compare result of uncrustify with changes + # + # only change any of the invocations here if + # they are portable across all cmp and shell + # implementations ! + uncrustify -q -c uncrustify.cfg -f $f | cmp -s $f - + if test $? = 1 ; + then + crustified=" $crustified $f" + RET=1 + fi + fi +done + +if [ $RET = 1 ]; +then + echo "Run" + echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}" + echo "before commiting." +fi +exit $RET |