News for hackers. Stuff that matters.
Re:Setting up Sublime Text 2 by ricardobeat on Tuesday April 09, 2013 @02:35PM (#5520114)
You shouldn't set "trim_trailing_white_space_on_save": true unless you work alone, otherwise you're going to have random whitespace changes polluting your diffs.
Re:Setting up Sublime Text 2 by maccman on Tuesday April 09, 2013 @02:40PM (#5520157)
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.

Re:Setting up Sublime Text 2 by stormbrew on Tuesday April 09, 2013 @06:27PM (#5521838)
The 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.

Re:Setting up Sublime Text 2 by foobar2k on Tuesday April 09, 2013 @03:04PM (#5520364)
The 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?

Re:Setting up Sublime Text 2 by senko on Tuesday April 09, 2013 @03:55PM (#5520821)
It'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).

Re:Setting up Sublime Text 2 by bct on Tuesday April 09, 2013 @06:09PM (#5521746)

    git diff --ignore-space-at-eol
Re:Setting up Sublime Text 2 by mixmastamyk on Tuesday April 09, 2013 @04:38PM (#5521167)
Trimming at the end of line has no effect on python.
Re:Setting up Sublime Text 2 by Silhouette on Tuesday April 09, 2013 @05:31PM (#5521551)
But other whitespace does, so globally disabling whitespace in a diff isn't very helpful.
Re:Setting up Sublime Text 2 by lucian1900 on Wednesday April 10, 2013 @07:05AM (#5524361)
You will never have silly diffs because someone accidentally changed some trailing whitespace (because there isn't any).
Re:Setting up Sublime Text 2 by chicagobob on Wednesday April 10, 2013 @12:14AM (#5523175)
we 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.
Re:Setting up Sublime Text 2 by tiedemann on Wednesday April 10, 2013 @04:57AM (#5523970)
That 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).
Re:Setting up Sublime Text 2 by matb33 on Wednesday April 10, 2013 @07:04AM (#5524357)
I turned that feature off because of Markdown. To force a carriage return, you need to have two spaces at the end of the line.
Re:Setting up Sublime Text 2 by forrestthewoods on Tuesday April 09, 2013 @05:59PM (#5521687)
It only pollutes your diffs if you're using a crappy diff tool. Whatever tool you use should have full control over showing leading, trailing, consecutive, or all whitespace differences.
Re:Setting up Sublime Text 2 by lobster_johnson on Tuesday April 09, 2013 @07:07PM (#5522067)
No, the main problem is that it screws up merges. Until Git can ignore trailing spaces as part of the merge strategy, it will be a problem when someone removes trailing spaces in one patch and someone else modifies (with real code) those same lines. If you have a largeish number of changes it will be a nightmare.
Re:Setting up Sublime Text 2 by tmhedberg on Tuesday April 09, 2013 @08:05PM (#5522333)
> Until Git can ignore trailing spaces as part of the merge strategy

It can:

    git merge -X ignore-space-at-eol
Re:Setting up Sublime Text 2 by lobster_johnson on Tuesday April 09, 2013 @09:59PM (#5522785)
Great, thanks!
Re:Setting up Sublime Text 2 by forrestthewoods on Tuesday April 09, 2013 @07:31PM (#5522190)
Araxis Merge, problem solved?
Re:Setting up Sublime Text 2 by lobster_johnson on Tuesday April 09, 2013 @07:34PM (#5522206)
I don't know it. But unless it's something that comes built into Git it's not useful. It needs to be something everyone has. That's the whole point.
Re:Setting up Sublime Text 2 by forrestthewoods on Tuesday April 09, 2013 @08:08PM (#5522349)
Nah. Use araxis merge and all your issues go away forever. If other devs want to use shitty tools then that's their fault. If you have a repo and are trying to merge pull requests then you definitely should stop using shitty tools. Even if you don't trim whitespace you should have non-shitty tools for local usage.

There's no reason to use shitty tools here.

Re:Setting up Sublime Text 2 by FuzzyDunlop on Tuesday April 09, 2013 @03:42PM (#5520697)
I think it's fine so long as everyone agrees, or as long as people don't strip the whitespace in the same commit as their actual changes.

Half the time the pointless whitespace is introduced by an editor that auto-indents for you.

Re:Setting up Sublime Text 2 by s00pcan on Tuesday April 09, 2013 @04:38PM (#5521171)
As opposed to having trailing whitespace and mixed tab/space whitespace polluting your diffs? Configure your diff viewer to ignore whitespace.