From d31342702e4128aac7dc9c3ac85f856868fbd479 Mon Sep 17 00:00:00 2001 From: ng0 Date: Thu, 21 Nov 2019 10:50:02 +0000 Subject: move configs in contrib to conf --- contrib/conf/uncrustify_precommit | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 contrib/conf/uncrustify_precommit (limited to 'contrib/conf/uncrustify_precommit') diff --git a/contrib/conf/uncrustify_precommit b/contrib/conf/uncrustify_precommit new file mode 100755 index 000000000..fd29998c3 --- /dev/null +++ b/contrib/conf/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 -- cgit v1.2.3