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

Hi,

> First, the three versions to use:
>
> BASE:
>  98: z1
>  99: z2
> 100: a() {
> 101: }
> 102:
> 103: b() {
> 104: }
>
> OURS:
>  98: z1
>  99: z2
> 100: a() {
> 101: }
> 102:
> 103: x() {
> 104: }
> 105:
> 103: b() {
> 104: }
>
> THEIRS:
>  98: x1
>  99: x2
> 100: a() {
> 101: }
> 102:
> 103: x() {
> 104: }
> 105:
> 106: b() {
> 107: }
>
> Diff BASE OURS, "strange" diff (L)
> insert lines 101-103 of OURS between 100 and 101 of BASE
>
> 101: }
> 102:
> 103: x() {
>
>
> Diff BASE THEIRS, plain diff (R)
> insert lines 103-105 of THEIRS between 102 and 103 of BASE
>
> 103: x() {
> 104: }
> 105:
>
> Then apply. Pick OURS, simple to apply onto BASE. However that alters the
> position where R should go next. Line 100 of BASE is still 100 since we insert
> after it, but we insert before 101, which is now 104. Next insert lines 103-105 of THEIRS
> between lines 101 and 104 of the result.  That's just silly => conflict.

The second diff was originally inserting between 102 and 103. Because
of the first insertion line 102 is now 105 and line 103 is now 106.
Therefore the second edit can now insert between 105 and 106. Where is
the problem? How could two insertions lead to a conflict if they don't
happen exactly between the same two lines of the base text?

I tried this out with native git and also native git is not reporting
an conflict here. Please clone
git@xxxxxxxxxx:chalstrick/mergeExample.git and try to merge
origin/side and origin/master.

Ciao
  Chris


Back to the top