1#!/bin/sh 2# 3# format.sh 4# 5# run clang-format on each .c & .h file 6# 7# assumes git tree is clean when reporting status 8 9if [ -z "${CLANG_FORMAT}" ]; then 10 CLANG_FORMAT=clang-format 11fi 12 13a=`git ls-files '*.h' '*.c'` 14for x in $a; do 15 if [ $x != "config_in.h" ]; then 16 $CLANG_FORMAT -i -style=file $x 17 fi 18done 19 20m=`git ls-files -m` 21if [ -n "$m" ]; then 22 v=`$CLANG_FORMAT -version` 23 echo "Fromatting required when checking with $v" 24 echo 25 echo "The following files required formatting:" 26 for f in $m; do 27 echo $f 28 done 29 if [ "$1" = "-d" ]; then 30 echo 31 git diff 32 fi 33 exit 1 34fi 35exit 0 36