Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is it bad to commit lines with trailing whitespace into source control?

Tags:

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

like image 696
readonly Avatar asked Nov 18 '08 23:11

readonly


People also ask

Why trailing whitespace is bad?

Some editors automatically remove trailing whitespace, some don't. This creates diff noise and can cause merge conflicts. You should coordinate with the people you're working with (colleagues, open-source crowd) what strategy everybody is using and make sure you all use the same strategy.

Why is whitespace bad?

Micro white space has a direct impact on content legibility. For example, marginal white space surrounding paragraphs affects the user's reading speed and comprehension. If text appears in margins outside regular paragraphs, people read it more slowly. They find it harder to understand than text without such margins.

What is trailing whitespace error?

Trailing whitespace is any spaces or tabs after the last non-whitespace character on the line until the newline. In your posted question, there is one extra space after try: , and there are 12 extra spaces after pass : >>> post_text = '''\ ...

What is leading or trailing whitespace?

A leading space is a space that is located before the first character (letter, number, punctuation mark) in a text entry field. A trailing space is a space that is located after the final character in a text entry field.


1 Answers

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.

like image 184
Jon Skeet Avatar answered Oct 13 '22 22:10

Jon Skeet