35 lines
696 B
Bash
Executable File
35 lines
696 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# use as .git/hooks/pre-commit
|
|
exec 1>&2
|
|
|
|
RET=0
|
|
changed=$(git diff --cached --name-only | grep -v mustach | grep -v templating/test./)
|
|
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 --replace -c uncrustify.cfg ${crustified}"
|
|
echo "before committing."
|
|
fi
|
|
exit $RET
|