Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] "instable" diff algorithms lead to wrong merge results

On Tue, Nov 9, 2010 at 7:27 AM, Christian Halstrick
<christian.halstrick@xxxxxxxxx> wrote:
> During that merge I get the following sets of Edits:
>
> base - ours (called baseToOurs): INSERT(19-19,19-20),
> INSERT(27-27,28-29), INSERT(28-28,30-31), INSERT(60-60,63-97)
> base - theirs (called baseToTheirs): INSERT(63-63,63-83)
...
> In our example I never fall into the conflict case --- all the edits
> are independent because they don't touch the same lines in the
> original text.

Do you consider "lines of context" when you do this?

I talked to Junio Hamano about this before I went out on leave.  C Git
uses the diff context lines as part of the overlapping test.  Since
the default is 3, they use 3 lines before and after each edit to
determine if there is a conflict with another edit from the other
side.

In our example above, baseToOurs should be looking at A ranges 57
through 63, and baseToTheirs should be looking at A ranges 60 through
66.  Since these overlap, you have a conflict, and can detect it.

Once you have the conflict, it may be possible to scrub the conflict
by looking at the leading and trailing segments elements and reducing
those that are common out of the conflict region.  This may cause the
conflict region to drop to 0 if they have both made the same edit.

-- 
Shawn.


Back to the top