4 ms·
Our coding guidelines at Stripe specify that whitespace is to be stripped. It works if everyone does it. On the occasion where whitespace does pollute the diff
by maccman 14y ago
Our coding guidelines at Stripe specify that whitespace is to be stripped. It works if everyone does it.
On the occasion where whitespace does pollute the diff, GitHub has a convenient feature where you can append '?w=1' to any diff URL and whitespace changes will be omitted.
- foobar2k 14y agoThe number of pull requests I get where the diffs are completely unreadable because someone has this feature enabled is insane. On certain whitespace dependent languages (I'm looking at you Python) simply supressing the whitespace in the diff is not an option. What are the arguments for having whitespace removal as a coding standard?
- senko 14y agoIt's dead easy to accidentally add (or remove) trailing whitespace, which you find out at git diff time. Unless you want to have whitespace changes in your commit, you have to manually revert those edits back. Having the editor just trim those automatically is just delegating the trailing whitespace care to a piece of software with a simple rule: no whitespace allowed. If the entire team working on a project agrees to this rule, everything's peachy, and it's really easy to convert an existing repo to it - whenever you touch a file, if there are whitespace changes, commit them to a separate commit. At the end of the day, it's just standard, so doing invasive changes to a project that doesn't follow that standard (as in the pull reqs you descibed) is wrong, but that doesn't mean the rule itself is bad. As for ST2, it allows easy per-project settings so you can easily enable it globally and disable on a specific project if needed (or vice versa).
- deleted 14y ago[deleted]
- mixmastamyk 14y agoTrimming at the end of line has no effect on python.
- Silhouette 14y agoBut other whitespace does, so globally disabling whitespace in a diff isn't very helpful.
- bct 14y agogit diff --ignore-space-at-eol
- lucian1900 14y agoYou will never have silly diffs because someone accidentally changed some trailing whitespace (because there isn't any).
- stormbrew 14y agoThe problem with universal whitespace removal isn't the output of the diff, imo, but the spurious conflicts in merges. A change should be minimal to allow easier merging. Ideally whitespace would be trimmed from lines that have otherwise changed, thus ensuring a gradual (though probably never completing) repair of the code.
- chicagobob 14y agowe also have a rule that when possible (like you've opened up an old file with whitespace issues), that you should clean it and do a whitespace changes only commit before getting to work. It makes everyone's life easier if they're not looking for the "real diff" in your commit.
- tiedemann 14y agoThat sounds great and diligent. Me and commits never seem to sync properly anyway (mostly because I am the sole dev on so many projects I guess).
- matb33 14y agoI turned that feature off because of Markdown. To force a carriage return, you need to have two spaces at the end of the line.