Bug 419641 - MergeCommand throws exception for conflicts with recursive merge (when merge base needs to be constructed)
Summary: MergeCommand throws exception for conflicts with recursive merge (when merge ...
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.2   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-16 18:15 EDT by Robin Stocker CLA
Modified: 2014-06-25 20:55 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Stocker CLA 2013-10-16 18:15:01 EDT
How to reproduce:

1. Set up a repository so that a real recursive merge is necessary (criss-cross) and there is a merge conflict
2. Merge using MergeCommand (not directly using RecursiveMerger)

Expected: MergeResult has CONFLICTING status
Actual: An exception is thrown:

Caused by: org.eclipse.jgit.errors.NoMergeBaseException: No merge base could be determined. Reason=CONFLICTS_DURING_MERGE_BASE_CALCULATION. "More than 200 merge bases for:
 a 3782cb9fd95b14a0a65ff1d3a4a0979d143fcbe8
 b dfab13c375aed49bb9d2f5b180602c19c99d2e8c found:
  count 2"
	at org.eclipse.jgit.merge.RecursiveMerger.getBaseCommit(RecursiveMerger.java:203)
	at org.eclipse.jgit.merge.RecursiveMerger.getBaseCommit(RecursiveMerger.java:126)
	at org.eclipse.jgit.merge.Merger.getBaseCommit(Merger.java:253)
	at org.eclipse.jgit.api.MergeCommand.call(MergeCommand.java:394)
	... 30 more

Fix upcoming.
Comment 1 Robin Stocker CLA 2013-10-16 18:18:08 EDT
https://git.eclipse.org/r/17436
Comment 4 EungJun Yi CLA 2014-06-24 06:11:29 EDT
There still remains a possibility of NoMergeBaseException for criss-cross merge.

For example, with this topology:

           ---1---o---A
               \ /
                X
               / \
           ---2---o---B

The exception will be thrown when merge A and B if 1 and 2 conflicts.

I guess jgit tries to merge merge bases between A and B and throws the exception if the merge bases conflict.
Comment 5 Robin Stocker CLA 2014-06-25 09:17:53 EDT
Could you open a new bug report for this? I'm also interested in what C Git does in a case like that.
Comment 6 Christian Halstrick CLA 2014-06-25 09:35:58 EDT
A little background on the jgit merge impl:

it's right: when jgit want's to merge two commits (A,B) and he finds out that these two commits have multiple common ancestors (1,2) then jgit will try try to produce a single common ancestor (3) by merging (1,2). I think native git does the same. I got that from the "recursive" section in [1].

Of course temporarily merging (1,2) can again lead into a situation with multiple common ancestors (1b, 2b) (criss-cross-criss-cross.....). Then the algorithm runs recursively to merge together (1b,2b) and use the result as ancestor to merge (1,2) and use the result as a ancestor to merge (A,B).

If merging common ancestors lead to conflicts then jgit gives up. Would be interesting to see what native git does.

[1] http://git-scm.com/docs/git-merge#_merge_strategies
Comment 7 EungJun Yi CLA 2014-06-25 20:55:06 EDT
I have opened a new bug report here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=438203