GNU diff3(三向合并)给出了意想不到的结果
假设文件 MINE 和 YOURS 是 OLD 的后代。
FILE_MINE=
abc def ghi
FILE_OLD=
abc jkl ghi
FILE_YOURS=
abc def ghi
命令 diff3 -m MIND OLD YOURS
给出:
abc <<<<<<< OLD jkl ======= def >>>>>>> YOURS ghi
diff3 无法解析 MINE 和 YOURS 所做的相同更改。
为什么?并且,有办法解决这个问题吗?
用这个来刺激你的大脑:
diff OLD MIND
和 diff OLD YOURS
在它们的输出中有相同的块。
2c2 < jkl --- > def
在三路合并期间,这些猛男不应该“取消”吗?
Assume that files MINE and YOURS are descendants of OLD.
FILE_MINE=
abc def ghi
FILE_OLD=
abc jkl ghi
FILE_YOURS=
abc def ghi
Command diff3 -m MIND OLD YOURS
gives:
abc <<<<<<< OLD jkl ======= def >>>>>>> YOURS ghi
diff3 cannot resolve that MINE and YOURS made identical changes.
Why? And, is there a way to resolve this issue?
Tickle your brain with this:
diff OLD MIND
and diff OLD YOURS
have identical hunks in their output.
2c2 < jkl --- > def
Should these hunks not "cancel-out" during the three-way merge?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你期望得到什么?
正如描述 diff3 实用程序的文章所说:
因此,您所描述的情况将被视为冲突。 “为什么会这样呢?”你可能会问。因为diff3算法。您可以在同一页面找到说明:
它无法正确解决差异,因为它没有进行更改的适当背景。
如果您要说它应该使用其他方法来工作,我会同意您的观点。但是……事情就是这样。 diff3 并不完美,如果您想按照文章
What did you expect to have?
As the article describing diff3 utility says:
Therefore, the case you've described is treated as a conflict. 'Why so?' you might ask. Because of the diff3 algorithm. Description you can find at the same page:
It cannot resolve differences properly because it does not have a proper context of changes being made.
I would agree with you if you're going to say that it should work using some other approach. But... it is what it is. diff3 is not perfect, I would recommend using other tools if you want to do it right as described in the article