challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

uncrustify_precommit (668B)


      1 #!/bin/sh
      2 
      3 # use as .git/hooks/pre-commit
      4 exec 1>&2
      5 
      6 RET=0
      7 changed=$(git diff --cached --name-only | grep -v mustach)
      8 crustified=""
      9 
     10 for f in $changed;
     11 do
     12  if echo $f | grep \\.[c,h]\$ > /dev/null
     13  then
     14     # compare result of uncrustify with changes
     15     #
     16     # only change any of the invocations here if
     17     # they are portable across all cmp and shell
     18     # implementations !
     19     uncrustify -q -c uncrustify.cfg -f $f | cmp -s $f -
     20     if test $? = 1 ;
     21     then
     22       crustified=" $crustified $f"
     23       RET=1
     24     fi
     25   fi
     26 done
     27 
     28 if [ $RET = 1 ];
     29 then
     30   echo "Run"
     31   echo "uncrustify --replace -c uncrustify.cfg ${crustified}"
     32   echo "before committing."
     33 fi
     34 exit $RET