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

别说谁变了你拦得住时间么 提交于 2021-02-18 08:56:49

问题


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


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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




回答5:


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.




回答6:


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



来源:https://stackoverflow.com/questions/300489/why-is-it-bad-to-commit-lines-with-trailing-whitespace-into-source-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!