srcCommit.getTree());
dco.setFailOnConflict(true);
dco.checkout();
String msg = null;
ObjectId newHead, base = null;
MergeStatus mergeStatus = null;
if (!squash) {
updateHead(refLogMessage, srcCommit, headId);
newHead = base = srcCommit;
mergeStatus = MergeStatus.FAST_FORWARD;
} else {
msg = JGitText.get().squashCommitNotUpdatingHEAD;
newHead = base = headId;
mergeStatus = MergeStatus.FAST_FORWARD_SQUASHED;
List<RevCommit> squashedCommits = RevWalkUtils.find(
revWalk, srcCommit, headCommit);
String squashMessage = new SquashMessageFormatter().format(
squashedCommits, head);
repo.writeSquashCommitMsg(squashMessage);
}
setCallable(false);
return new MergeResult(newHead, base, new ObjectId[] {
headCommit, srcCommit }, mergeStatus, mergeStrategy,
null, msg);
} else {
if (fastForwardMode == FastForwardMode.FF_ONLY) {
return new MergeResult(headCommit, srcCommit,
new ObjectId[] { headCommit, srcCommit },
MergeStatus.ABORTED, mergeStrategy, null, null);
}
String mergeMessage = ""; //$NON-NLS-1$
if (!squash) {
if (message != null)
mergeMessage = message;
else
mergeMessage = new MergeMessageFormatter().format(
commits, head);
repo.writeMergeCommitMsg(mergeMessage);
repo.writeMergeHeads(Arrays.asList(ref.getObjectId()));
} else {
List<RevCommit> squashedCommits = RevWalkUtils.find(
revWalk, srcCommit, headCommit);
String squashMessage = new SquashMessageFormatter().format(
squashedCommits, head);
repo.writeSquashCommitMsg(squashMessage);
}
Merger merger = mergeStrategy.newMerger(repo);
boolean noProblems;
Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
Map<String, MergeFailureReason> failingPaths = null;
List<String> unmergedPaths = null;
if (merger instanceof ResolveMerger) {
ResolveMerger resolveMerger = (ResolveMerger) merger;
resolveMerger.setCommitNames(new String[] {
"BASE", "HEAD", ref.getName() }); //$NON-NLS-1$ //$NON-NLS-2$
resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
noProblems = merger.merge(headCommit, srcCommit);
lowLevelResults = resolveMerger
.getMergeResults();
failingPaths = resolveMerger.getFailingPaths();
unmergedPaths = resolveMerger.getUnmergedPaths();
} else
noProblems = merger.merge(headCommit, srcCommit);
refLogMessage.append(": Merge made by "); //$NON-NLS-1$
if (!revWalk.isMergedInto(headCommit, srcCommit))
refLogMessage.append(mergeStrategy.getName());
else
refLogMessage.append("recursive"); //$NON-NLS-1$
refLogMessage.append('.');
if (noProblems) {
dco = new DirCacheCheckout(repo,
headCommit.getTree(), repo.lockDirCache(),
merger.getResultTreeId());
dco.setFailOnConflict(true);
dco.checkout();
String msg = null;
ObjectId newHeadId = null;
MergeStatus mergeStatus = null;
if (!commit && squash) {
mergeStatus = MergeStatus.MERGED_SQUASHED_NOT_COMMITTED;
}
if (!commit && !squash) {
mergeStatus = MergeStatus.MERGED_NOT_COMMITTED;