Created
August 27, 2011 09:25
-
-
Save wezm/1175182 to your computer and use it in GitHub Desktop.
Strip trailing whitespace in modified files tracked by git
This file contains 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/sh | |
git ls-files --modified '*.[hm]' | xargs sed -i '.bak' 's/[[:space:]]*$//' |
I started getting this problem too. It happens when the files aren't in the top level of the project. I've come up with a shorter, better script as a result. Gist, updated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I ran this on an unmodified project generated from the "Master-Detail Application" template, I got the following error:
When I removed the quotes from around
$modified_files
in thesed
command, it worked. My working version looks like this:Not sure if there was something weird on my setup or what, but that's what worked for me.