Browse Source

Only execute preformat hook on supported files

Stefan Profanter 5 years ago
parent
commit
46fe8c37ae
1 changed files with 9 additions and 2 deletions
  1. 9 2
      tools/clang-format_precommit_hook

+ 9 - 2
tools/clang-format_precommit_hook

@@ -5,7 +5,7 @@
 # the staged changes.
 #
 # To install, copy this script to `.git/hooks/pre-commit`:
-# ln -s ../../tools/clang-format_precommit_hook .git/hooks/pre-commit
+# cd .git/hooks && ln -s ../../tools/clang-format_precommit_hook pre-commit
 # and make sure that `clang-format` is installed on your system
 
 maj_min=1
@@ -52,5 +52,12 @@ fi
 # do the formatting
 for file in `git diff-index --cached --name-only $against`
 do
-    "$format" -i "$file"
+    case "$file" in
+    *.h | *.hpp | *.c | *.cpp )
+            "$format" -i "$file"
+            ;;
+    *)
+            # do nothing with file
+            ;;
+    esac
 done