Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1e73e565b0
Fetching contributors…

Cannot retrieve contributors at this time

executable file 27 lines (21 sloc) 0.627 kb
#!/bin/bash
#
# A precommit hook that checks the files in the index for trailing whitespace.
# If it finds any, it will automatically strip the whitespace from those files
# and update the index before the commit takes place.
if git rev-parse --verify HEAD > /dev/null
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=0000000000000000000000000000000000000000
fi
old_IFS=$IFS
IFS=$'\n'
for FILE in `git diff-index --check --cached $against 2>&1 | sed '/^[\*\+]/d' | sed 's/:.*//' | uniq` ; do
sed -ie 's/[[:space:]]*$//' $FILE
rm $FILE"e"
git add $FILE
done
IFS=$old_IFS
exit 0
Jump to Line
Something went wrong with that request. Please try again.