views:

370

answers:

6

Why is it bad to check in lines with trailing whitespace to your source control? What kinds of problems could that cause?

+10  A: 

False differences, basically. It's helpful if diffs only show "real" changes. Some diff programs will ignore whitespace, but it would be better just to avoid the dummy change in the first place.

Of course, it also doesn't help if it makes the line wrap on a colleague's machine.

Jon Skeet
Also a reason not to check-in commented-out code.
Scott A. Lawrence
Yeah! I hate that :) Delete the code if it's already in source control!
Jason Coco
But... if your repo already HAS whitespace in it, and you, trying to be helpful, take it OUT, then YOU'RE the one creating a false difference. ;)
Pistos
+2  A: 

Because many people remove them you will have them show up as modified lines in diff tools if you don't use all the options (say a plain old cvs diff) which means people see your line for no good reason.

In theory you could also have strings that wrap lines where whitespace would truly be bad, but... probably not your issue.

Oskar
+1  A: 

Yeah, I sort of agree with the other posts, but I would add that it's not bad per se. It is not a great practice, but that's the sort of thing that happens and you just sort of sigh and get on with things.

Travis
+1  A: 

It's like painting your walls, but not finishing the edges off properly, and going right onto the skirting board.

Ali A
A: 

Modern diff utilities don't get hung up on whitespace.

Dustin Getz
+2  A: 

Some editors automatically remove trailing whitespace, some don't. This creates diff noise and can cause merge conflicts.

Baczek