Source:
<code>public MergeResult call() throws NoHeadException, ConcurrentRefUpdateException { checkCallable(); try { Ref head = repo.getRef(Constants.HEAD); if (head == null) throw new NoHeadException( "Commit on repo without HEAD currently not supported"); StringBuilder refLogMessage = new StringBuilder("merge "); refLogMessage.append(commit.getName() + ": "); RevWalk revWalk = new RevWalk(repo); RevCommit headCommit = revWalk.lookupCommit(head.getObjectId()); <START> RevCommit srcCommit = revWalk.lookupCommit(commit.getLeaf() <END> .getObjectId()); if (revWalk.isMergedInto(srcCommit, headCommit)) { return new MergeResult(headCommit, MergeResult.MergeStatus.ALREADY_UP_TO_DATE, mergeStrategy); } Commit newHeadCommit; MergeResult.MergeStatus mergeStatus = null; if (revWalk.isMergedInto(headCommit, srcCommit)) { newHeadCommit = repo.mapCommit(srcCommit); refLogMessage.append("Fast forward"); mergeStatus = MergeResult.MergeStatus.FAST_FORWARD; } else { return new MergeResult(null, MergeResult.MergeStatus.NOT_SUPPORTED, mergeStrategy, "only already-up-to-date and fast forward merges are available"); } checkoutNewHead(revWalk, headCommit, newHeadCommit); return updateHead(refLogMessage, newHeadCommit, mergeStatus); } catch (IOException e) { throw new JGitInternalException( "Exception caught during execution of merge command", e); } }</code><technical_language>FWIW, getLeaf() necessary. getObjectId() works symbolic references traversing leaf get value</technical_language>

Target:
public MergeResult call() throws NoHeadException, ConcurrentRefUpdateException, CheckoutConflictException { checkCallable(); try { Ref head = repo.getRef(Constants.HEAD); if (head == null) throw new NoHeadException( "Commit on repo without HEAD currently not supported"); StringBuilder refLogMessage = new StringBuilder("merge "); RevWalk revWalk = new RevWalk(repo); RevCommit headCommit = revWalk.lookupCommit(head.getObjectId()); RevCommit newHeadCommit = null; MergeStatus mergeStatus = MergeResult.MergeStatus.ALREADY_UP_TO_DATE; boolean firstEntry=true; for (Map.Entry<String, AnyObjectId> commitEntry: commits.entrySet()) { if (!firstEntry) refLogMessage.append(", "); firstEntry = false; refLogMessage.append(commitEntry.getKey()); RevCommit srcCommit = revWalk.lookupCommit(commitEntry.getValue()); if (revWalk.isMergedInto(srcCommit, headCommit)) { } else if (revWalk.isMergedInto(headCommit, srcCommit)) { if (newHeadCommit == null || revWalk.isMergedInto(newHeadCommit, srcCommit)) newHeadCommit = srcCommit; mergeStatus = MergeResult.MergeStatus.FAST_FORWARD; } else { mergeStatus = MergeResult.MergeStatus.NOT_SUPPORTED; break; } } if (mergeStatus==MergeStatus.ALREADY_UP_TO_DATE) return new MergeResult(headCommit, mergeStatus, mergeStrategy); else if (mergeStatus==MergeStatus.FAST_FORWARD) { refLogMessage.append(": Fast forward"); checkoutNewHead(revWalk, headCommit, newHeadCommit); return updateHead(refLogMessage, newHeadCommit, head.getObjectId(), mergeStatus); } else return new MergeResult(null, MergeResult.MergeStatus.NOT_SUPPORTED, mergeStrategy, "only already-up-to-date and fast forward merges are available"); } catch (IOException e) { throw new JGitInternalException( "Exception caught during execution of merge command", e); } }