I read an article about three-way merges (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 O-A and after O-B:
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
:
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;"
, to "a=0;"
user 2 update "b;"
, to "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
)! 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.