Skip to content

Commit

Permalink
don't blank committed files if wtf can't be run
Browse files Browse the repository at this point in the history
  • Loading branch information
dlenski committed Jun 19, 2016
1 parent 8bd8728 commit ac32969
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pre-commit.careful
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ git diff-index --cached HEAD --diff-filter=ACMRTU |
while read _ MODE _ SHA1 _ FILE
do
if ! ( git cat-file blob $SHA1 | wtf $wtf_options > $tmp ); then
git update-index --cacheinfo $MODE $(git hash-object -w $tmp) "$FILE"
echo "Fixed whitespace in $FILE" >&2
if [ -s $tmp ]; then
git update-index --cacheinfo $MODE $(git hash-object -w $tmp) "$FILE"
echo "Fixed whitespace in $FILE" >&2
else
echo "Couldn't fix whitespace with wtf -- is it in your PATH?" >&2
fi
fi
done
rm -f $tmp 2> /dev/null

0 comments on commit ac32969

Please sign in to comment.