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

Here is now a concrete real-life example:
- clone egit from git://egit.eclipse.org/egit.git
- checkout 3e494ae and then merge cb2e630 (try the merge with native
git and with EGit)
- inspect lines 66-118 of file
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/EgitUiEditorUtils.java

Problem: Native git reports a conflict during merge and JGit
(regardless wether we use Myers- or HistogramDiff) does not
Reason: Both commits insert a new method at the same position of the
original text. They don't insert the same method but two different
methods. But in JGit when comparing BASE and OURS the insertion is at
line X and when comparing BASE and THEIRS the insertion is at line
X+2. That means for JGit these insertions are independent and don't
produce a conflict. Native git seems to produce the same
insertion-point when comparing BASE and OURS and BASE and THEIRS - and
therefore report an conflict.

To get a clue what JGit merge algorithm is doing you may want to
cherry-pick 4d3fb76 from git@xxxxxxxxxx:chalstrick/jgit.git which adds
some log statements. The logs which I got have been the following:
...
ResolveMerger,21:56:39:611: Handling path
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/EgitErrorEditor.java
ResolveMerger,21:56:39:611: Handling path
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/EgitUiEditorUtils.java
MergeAlgorithm,21:56:39:611: Starting ours:
org.eclipse.jgit.diff.RawTextComparator$1@cf9a33, theirs:
org.eclipse.jgit.diff.RawText@d25883, cmp:
org.eclipse.jgit.diff.RawText@1b1407a, base:
org.eclipse.jgit.diff.RawText@3589
MergeAlgorithm,21:56:39:626: diffed ours:
EditList[INSERT(19-19,19-20), INSERT(27-27,28-29),
INSERT(28-28,30-31), INSERT(60-60,63-97)]
MergeAlgorithm,21:56:39:626: diffed theirs: EditList[INSERT(63-63,63-83)]
MergeAlgorithm,21:56:39:626: entering the mainloop
MergeAlgorithm,21:56:39:626: working on these edits oursEdit:
INSERT(19-19,19-20), theirsEdit: INSERT(63-63,63-83)
MergeAlgorithm,21:56:39:626: non-conflicting, take ours
MergeAlgorithm,21:56:39:626: working on these edits oursEdit:
INSERT(27-27,28-29), theirsEdit: INSERT(63-63,63-83)
MergeAlgorithm,21:56:39:626: non-conflicting, take ours
MergeAlgorithm,21:56:39:626: working on these edits oursEdit:
INSERT(28-28,30-31), theirsEdit: INSERT(63-63,63-83)
MergeAlgorithm,21:56:39:626: non-conflicting, take ours
MergeAlgorithm,21:56:39:626: working on these edits oursEdit:
INSERT(60-60,63-97), theirsEdit: INSERT(63-63,63-83)
MergeAlgorithm,21:56:39:626: non-conflicting, take ours
MergeAlgorithm,21:56:39:626: working on these edits oursEdit:
EMPTY(2147483647-2147483647,2147483647-2147483647), theirsEdit:
INSERT(63-63,63-83)
MergeAlgorithm,21:56:39:626: non-conflicting, take theirs
MergeAlgorithm,21:56:39:626: mainloop ended
MergeAlgorithm,21:56:39:626: added some common non-handled part after
the last edit. from: 63, to: 161
ResolveMerger,21:56:39:642: Handling path
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/FileRevisionEditorInput.java
...


Ciao
  Chris


Back to the top