GNU diff3(三向合并)给出了意外结果 [英] GNU diff3 (three-way merge) gives unexpected result

查看:217
本文介绍了GNU diff3(三向合并)给出了意外结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假定文件MINE和YOURS是OLD的后代.

Assume that files MINE and YOURS are descendants of OLD.

FILE_MINE =

FILE_MINE=


abc
def
ghi

FILE_OLD =

FILE_OLD=


abc
jkl
ghi

FILE_YOURS =

FILE_YOURS=


abc
def
ghi

命令diff3 -m MIND OLD YOURS给出:


abc
<<<<<<< OLD
jkl
=======
def
>>>>>>> YOURS
ghi

diff3无法确定MINE和您的所做的相同更改.

diff3 cannot resolve that MINE and YOURS made identical changes.

为什么?而且,有没有办法解决这个问题?

Why? And, is there a way to resolve this issue?

以此来动动你的大脑:

diff OLD MINDdiff OLD YOURS在其输出中具有相同的块.

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?

推荐答案

您期望得到什么?

作为描述diff3实用程序的文章说:

...当所有三个输入文件都不同时,或者只有较旧的时候不同时,此(合并)不能为真;我们称这为冲突.当所有三个输入文件都不相同时,我们将冲突称为 overlap

... This (merging) fails to be true when all three input files differ or when only older differs; we call this a conflict. When all three input files differ, we call the conflict an overlap

因此,您所描述的情况被视为冲突. '为什么这样?'你可能会问.由于diff3算法.您可以在同一页面上找到说明:

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:

您可以认为此(合并)是从您的中减去 older ,并将结果添加到 mine 中,或者是合并到会变得更老的变化

You can think of this (merging) as subtracting older from yours and adding the result to mine, or as merging into mine the changes that would turn older into yours

由于没有适当的更改上下文,因此无法正确解决差异.

It cannot resolve differences properly because it does not have a proper context of changes being made.

如果您要说它应该使用其他方法工作,我会同意您的看法.但是它就是这样啊. diff3并不完美,如果您想要按照文章文章

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

这篇关于GNU diff3(三向合并)给出了意外结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆