fix hook to only apply to C code
authorChristian Grothoff <christian@grothoff.org>
Sat, 5 Oct 2019 12:55:12 +0000 (14:55 +0200)
committerChristian Grothoff <christian@grothoff.org>
Sat, 5 Oct 2019 12:55:12 +0000 (14:55 +0200)
contrib/uncrustify_precommit

index bf7bac4ef947533b5bdf9bb1377c0b33892417fe..a370277cce2f303202fe4ce1fc669089b1cafee2 100644 (file)
@@ -5,30 +5,31 @@
 exec 1>&2
 
 RET=0
-
 changed=$(git diff --cached --name-only)
 crustified=""
 
 for f in $changed;
 do
-    # 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
+  # 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
+      if echo $f | grep \\.[c,h]\$ > /dev/null
+      then
         crustified=" $crustified $f"
         RET=1
-    fi
+      fi
+  fi
 done
 
 if [ $RET = 1 ];
 then
-    echo "Run"
-    echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}"
-    echo "before commiting."
+  echo "Run"
+  echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}"
+  echo "before commiting."
 fi
-
 exit $RET