Taking corrective action with git pre-commit
eng.wealthfront.com
Taking corrective action with git pre-commit
1–4 of 4 posts
Re: Taking corrective action with git pre-commit
#2Worse 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 :-)
Re: Taking corrective action with git pre-commit
#3If 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…
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.
Re: Taking corrective action with git pre-commit
#4If 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…