Created
February 2, 2016 01:16
-
-
Save lwalen/d882b225850575eca9f7 to your computer and use it in GitHub Desktop.
Removes trailing whitespace from modified lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git diff --cached --no-color > stage.diff && \ | |
git apply --index -R stage.diff && \ | |
git apply --index --whitespace=fix stage.diff &> log.txt && \ | |
removals=$(egrep -v '(stage.diff:|warning:)' log.txt | wc -l | tr -d '[[:space:]]') && \ | |
echo "whitespace removed from $removals line$([ $removals -ne 1 ] && echo 's')" && \ | |
rm -f stage.diff log.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment