Community
Participate
Working Groups
The RecursiveMerger will throw a NPE when there is no merge base for the commits it is trying to merge. Example stack trace [1]. [1] Caused by: java.lang.NullPointerException: while trying to invoke the method org.eclipse.jgit.revwalk.RevCommit.getTree() of a null object returned from org.eclipse.jgit.merge.RecursiveMerger.getBaseCommit(org.eclipse.jgit.revwalk.RevCommit, org.eclipse.jgit.revwalk.RevCommit, int) at org.eclipse.jgit.merge.RecursiveMerger.getBaseCommit(RecursiveMerger.java:197) at org.eclipse.jgit.merge.RecursiveMerger.getBaseCommit(RecursiveMerger.java:125) at org.eclipse.jgit.merge.ThreeWayMerger.mergeBase(ThreeWayMerger.java:132) at org.eclipse.jgit.merge.ResolveMerger.mergeImpl(ResolveMerger.java:301) at org.eclipse.jgit.merge.Merger.merge(Merger.java:203) at org.eclipse.jgit.merge.Merger.merge(Merger.java:156) at org.eclipse.jgit.merge.ThreeWayMerger.merge(ThreeWayMerger.java:114)
I debugged and found out that this is a bug when JGit should merge two tips which have no common ancestor (the repo has at least two roots r1,r2 and one tip is ancestor of r1 and the other of r2). Not all such cases are buggy ... but some of them are. And we have no test for that. Definitly a severe bug. I'll continue fixing and writing tests which cover this. At least the situation is reproducable.
The bug was not as bad as thought in the beginning. To hit this bug it was not necessary that the commits you want to merge don't have a common predecessor. Instead it was required that you - want to merge m1, m2 - m1 and m2 have multiple common base commits b1, b2 (means: there was a criss-cross merge) - the found base commits b1, b2 don't have a common predecessor (they are derived from different root commits) Example: m1--m2 \/ /\ s1--s2 In this case m1 and s2 do have common base commits (m1 & s1) but these base commits have no common base. Proposed a fix here: https://git.eclipse.org/r/#/c/44567