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

后端 未结 6 1097
渐次进展
渐次进展 2021-02-18 14:59

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

相关标签:
6条回答
  • 2021-02-18 15:14

    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.

    0 讨论(0)
  • 2021-02-18 15:19

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

    0 讨论(0)
  • 2021-02-18 15:19

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

    0 讨论(0)
  • 2021-02-18 15:26

    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.

    0 讨论(0)
  • 2021-02-18 15:29

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

    0 讨论(0)
  • 2021-02-18 15:33

    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.

    0 讨论(0)
提交回复
热议问题