pre-commit (1103B)
1 #!/bin/sh 2 3 PARAMS="--align-with-spaces \ 4 --blank-lines-after-declarations \ 5 --blank-lines-after-procedures \ 6 --blank-lines-before-block-comments \ 7 --brace-indent 0 \ 8 --braces-on-if-line \ 9 --braces-on-func-def-line \ 10 --braces-on-struct-decl-line \ 11 --break-before-boolean-operator \ 12 --case-indentation 0 \ 13 --continue-at-parentheses \ 14 --cuddle-else \ 15 --declaration-indentation 16 \ 16 --ignore-newlines \ 17 --indent-label -1 \ 18 --indent-level 8 \ 19 --line-length 80 \ 20 --no-blank-lines-after-commas \ 21 --no-space-after-casts \ 22 --no-space-after-for \ 23 --no-space-after-function-call-names \ 24 --no-space-after-if \ 25 --no-space-after-while \ 26 --preprocessor-indentation 2 \ 27 --swallow-optional-blank-lines \ 28 --use-tabs" 29 30 code=0 31 32 for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR | grep -E "(\.c|\.h)$"` ; do 33 tmpfile=`mktemp /tmp/XXXXXX` || exit 1 34 cp $file $tmpfile 35 VERSION_CONTROL=none indent $PARAMS $file 2>> /dev/null 36 diff -u -p $tmpfile $file 2>> /dev/null 37 res=$? 38 rm $tmpfile 39 if [ $res != 0 ] ; then 40 echo "Code style error in $file" 41 code=1 42 fi 43 done 44 45 exit $code