Source:
<code>public MergeResult call() throws NoHeadException, ConcurrentRefUpdateException, CheckoutConflictException { <START> checkCallable(); <END> try { Ref head = repo.getRef(Constants.HEAD); if (head == null) throw new NoHeadException(JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); 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(mergeStatus.toString()); checkoutNewHead(revWalk, headCommit, newHeadCommit); return updateHead(refLogMessage, newHeadCommit, head.getObjectId(), mergeStatus); } else return new MergeResult( null, MergeResult.MergeStatus.NOT_SUPPORTED, mergeStrategy, JGitText.get().onlyAlreadyUpToDateAndFastForwardMergesAreAvailable); } catch (IOException e) { throw new JGitInternalException( MessageFormat.format( JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand, e)); } }</code><technical_language>abort if commits is empty. need other merge besides head</technical_language>

Target:
public MergeResult call() throws NoHeadException, ConcurrentRefUpdateException, CheckoutConflictException, InvalidMergeHeadsException { checkCallable(); if (commits.size() != 1) throw new InvalidMergeHeadsException( commits.isEmpty() ? JGitText.get().noMergeHeadSpecified : MessageFormat.format( JGitText.get().mergeStrategyDoesNotSupportHeads, mergeStrategy.getName(), commits.size())); try { Ref head = repo.getRef(Constants.HEAD); if (head == null) throw new NoHeadException(JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported); StringBuilder refLogMessage = new StringBuilder("merge "); RevWalk revWalk = new RevWalk(repo); RevCommit headCommit = revWalk.lookupCommit(head.getObjectId()); Ref ref = commits.get(0); refLogMessage.append(ref.getName()); ObjectId objectId = ref.getPeeledObjectId(); if (objectId == null) objectId = ref.getObjectId(); RevCommit srcCommit = revWalk.lookupCommit(objectId); if (revWalk.isMergedInto(srcCommit, headCommit)) { setCallable(false); return new MergeResult(headCommit, MergeStatus.ALREADY_UP_TO_DATE, mergeStrategy); } else if (revWalk.isMergedInto(headCommit, srcCommit)) { refLogMessage.append(": " + MergeStatus.FAST_FORWARD); checkoutNewHead(revWalk, headCommit, srcCommit); updateHead(refLogMessage, srcCommit, head.getObjectId()); setCallable(false); return new MergeResult(srcCommit, MergeStatus.FAST_FORWARD, mergeStrategy); } else { return new MergeResult( headCommit, MergeResult.MergeStatus.NOT_SUPPORTED, mergeStrategy, JGitText.get().onlyAlreadyUpToDateAndFastForwardMergesAreAvailable); } } catch (IOException e) { throw new JGitInternalException( MessageFormat.format( JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand, e)); } }