[英]Strange conflict on git
I read an article about three-way merges (diff3). 我读了一篇关于三向合并的文章(diff3)。 It gives an example about how is detects a conflict.
它给出了一个如何检测冲突的示例。 The example is :
例子是:
A=[1,4,5,2,3,6]
O=[1,2,3,4,5,6] <<< Origin
B=[1,2,4,5,3,6]
In the first time it computes the diff between OA and after OB: 在第一次计算OA和OB之后的差异时:
A=[1,4,5,2,3, ,6]
O=[1, ,2,3,4,5,6]
and 和
O=[1,2,3,4,5, ,6]
B=[1,2, ,4,5,3,6]
After it makes diff3 parse
: 在它进行
diff3 parse
:
A=[1,4,5,2, 3 ,6] O=[1, ,2, 3,4,5 ,6] <<< Origin B=[1, ,2, 4,5,3 ,6]
And after it detects the conflict : 在发现冲突后:
1
4
5
2
<<<<<<<<<A
3
|||||||O
3
4
5
=======
4
5
3
>>>>>>B
6
Following this method to detect the conflict, i try a simple example : initially i have the document : 按照这种方法来检测冲突,我尝试一个简单的例子:最初我有文件:
a;
b;
i make an updates user 1 update "a;"
我做更新用户1更新
"a;"
, to "a=0;"
,到
"a=0;"
user 2 update "b;"
用户2更新
"b;"
, to "b=0;"
,到
"b=0;"
I obtain this result : 我得到了这个结果:
xx
<<<<<<< A
int a=0;
int b;
||||||| O
int a;
int b;
=======
int a;
int b=0;
>>>
When i merge these two documents i have a conflict even if i don't change at the same position ( a and b are not at the same position
)! 当我合并这两个文件时,即使我没有在同一位置改变(
a and b are not at the same position
),我也会发生冲突! some one can explain me why i have this conflict ? 有人可以解释我为什么会有这种冲突?
This question is very similar to this one , and the answer also is: That's because each diff hunk does not only consist of the literal difference but also of some lines of context that are required to locate the difference in a file that has some lines added / removed and thus the hunk offset changes. 这个问题是非常相似, 这一次 ,得到的回答也是:这是因为每一个差异大块不仅包括字面差异,而且上下文的一些行所需要的定位是增加了一些行的文件的区别/删除,因此大块的偏移量发生变化。 A difference in the context is also a conflict because depending on what patch you would apply first you're changing the context for the other patch.
上下文中的差异也是一种冲突,因为根据您首先应用的补丁,您将更改其他补丁的上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.