If you are working with a legacy repository that might still have some files in it with whitespace issues (if you are using svn, you are not merging and thus not caring about trailing whitespace), this is a sure-fire way to create commits that change both code and whitespace.
Worse than not fixing trailing whitespace (or only fixing it in the lines you are actually changing) is fixing whitespace AND changing the code in the same commit.
Doing something like what's proposed in the article is acceptable as long as you do even more shell magic so it only works on lines actually touched by the commit.
Same goes for scripts running on the server (just doing validation there of course!). You can only act on lines actually changed by the commit if you're dealing with repositories imported from pre-git days, or you will be seriously hated by your teammates :-)
Not really. Diff -uw ignores whitespace, so this is not really a crisis.
Personally, I prefer to just rewrite the whole tree in one go, but that scares a lot of people. So just commit the fix and it will all work out in the end.
If you're working with a legacy repository, quit your job. Work somewhere where you are empowered to do what will make you and your team more efficient. I nuked trailing whitespace in our whole repo at wealthfront when I added the whitespace check to our pre-commit hook.
3 comments
[ 2.7 ms ] story [ 15.0 ms ] threadWorse than not fixing trailing whitespace (or only fixing it in the lines you are actually changing) is fixing whitespace AND changing the code in the same commit.
Doing something like what's proposed in the article is acceptable as long as you do even more shell magic so it only works on lines actually touched by the commit.
Same goes for scripts running on the server (just doing validation there of course!). You can only act on lines actually changed by the commit if you're dealing with repositories imported from pre-git days, or you will be seriously hated by your teammates :-)
Personally, I prefer to just rewrite the whole tree in one go, but that scares a lot of people. So just commit the fix and it will all work out in the end.