pre-commit script: only run on files that exist, not deleted files.
authorMichael Smith <msmith@songbirdnest.com>
Tue, 10 Feb 2009 20:17:10 +0000 (12:17 -0800)
committerMichael Smith <msmith@songbirdnest.com>
Tue, 10 Feb 2009 20:17:10 +0000 (12:17 -0800)
Add --diff-filter=ACMR to only get added, copied, modified, or renamed
files (importantly, not deleted files!) in the list of files we run the
indent script on.

hooks/pre-commit.hook

index a896fa4..e538fbd 100755 (executable)
@@ -19,7 +19,7 @@ INDENT_PARAMETERS="--braces-on-if-line \
        --indent-level2"
  
 echo "--Checking style--"
-for file in `git-diff-index --cached --name-only HEAD | grep "\.c$"` ; do
+for file in `git-diff-index --cached --name-only HEAD --diff-filter=ACMR| grep "\.c$"` ; do
     # nf is the temporary checkout. This makes sure we check against the
     # revision in the index (and not the checked out version).
     nf=`git checkout-index --temp ${file} | cut -f 1`