From: ng0 Date: Sun, 29 Sep 2019 10:30:10 +0000 (+0000) Subject: add precommit hook example X-Git-Tag: v0.11.7~104 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dd298ca059ed935560cccfa020127c93b4d3f823;p=oweals%2Fgnunet.git add precommit hook example --- diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit new file mode 100644 index 000000000..bf7bac4ef --- /dev/null +++ b/contrib/uncrustify_precommit @@ -0,0 +1,34 @@ +#!/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 + # 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 +done + +if [ $RET = 1 ]; +then + echo "Run" + echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}" + echo "before commiting." +fi + +exit $RET