]> source.dussan.org Git - jgit.git/commit
Fix exception on conflicts with recursive merge 36/17436/3
authorRobin Stocker <robin@nibor.org>
Wed, 16 Oct 2013 21:51:24 +0000 (23:51 +0200)
committerRobin Stocker <robin@nibor.org>
Tue, 3 Dec 2013 20:05:37 +0000 (21:05 +0100)
commit7dc8a4f089c1ca4762cf6fbf2e77898607a5820a
tree61fc8c9e579ab08880fbd17e396ad5d90272bb47
parent1128326adde8f2c98bddc58ce1879fca7b2cd41f
Fix exception on conflicts with recursive merge

When there are conflicts with a recursive merge, the conflicting paths
are stored in unmergedPaths (field in ResolveMerger). Later, when the
MergeResult is constructed in MergeCommand, getBaseCommit is called,
which computes the merge base a second time.

In case of RecursiveMerger, getBaseCommit merges the multiple merge
bases into one. It does this not by creating a new ResolveMerger but
instead calling mergeTrees. The problem with mergeTrees is that at the
end, it checks if unmergedPaths is non-empty and returns false in that
case.

Because unmergedPaths was already non-empty because of the real merge,
it thinks that there were conflicts when computing the merge base again,
when there really were none.

This can be fixed by storing the base commit when computing it and then
returning that instead of computing it a second time.

Note that another possible fix would be to just use a new ResolveMerger
for merging the merge bases instead. This would also remove the need to
remember the old value of dircache, inCore and workingTreeIterator (see
RecursiveMerger#getBaseCommit).

Bug: 419641
Change-Id: Ib2ebf4e177498c22a9098aa225e3cfcf16bbd958
Signed-off-by: Robin Stocker <robin@nibor.org>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RevertCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/StrategyOneSided.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/ThreeWayMerger.java