Re:Taking corrective action with git pre-commit
by 2is10 on Tuesday March 08, 2011 @01:55PM
(#2302081)
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.
Re:Taking corrective action with git pre-commit
by jrockway on Tuesday March 08, 2011 @11:46AM
(#2301536)
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.
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 :-)