From 5dbef3fa51053b37f68b44ed390cab6dc8336dcc Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Wed, 6 Apr 2011 22:55:10 +0200 Subject: Add "Conflicts" section to merge message on conflict The same as with cherry-pick, the commit message of a merge should include a "Conflicts" section when the merge resulted in conflicts. Change-Id: I6261dc898262322924af5ca1bef841a654b0df55 Signed-off-by: Robin Stocker --- .../src/org/eclipse/jgit/api/MergeCommand.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'org.eclipse.jgit') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java index 39c079896b..5e77565562 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java @@ -189,14 +189,16 @@ public class MergeCommand extends GitCommand { mergeStrategy, null, null); } else { - repo.writeMergeCommitMsg(new MergeMessageFormatter().format( - commits, head)); + String mergeMessage = new MergeMessageFormatter().format( + commits, head); + repo.writeMergeCommitMsg(mergeMessage); repo.writeMergeHeads(Arrays.asList(ref.getObjectId())); ThreeWayMerger merger = (ThreeWayMerger) mergeStrategy .newMerger(repo); boolean noProblems; Map> lowLevelResults = null; Map failingPaths = null; + List unmergedPaths = null; if (merger instanceof ResolveMerger) { ResolveMerger resolveMerger = (ResolveMerger) merger; resolveMerger.setCommitNames(new String[] { @@ -206,6 +208,7 @@ public class MergeCommand extends GitCommand { lowLevelResults = resolveMerger .getMergeResults(); failingPaths = resolveMerger.getFailingPaths(); + unmergedPaths = resolveMerger.getUnmergedPaths(); } else noProblems = merger.merge(headCommit, srcCommit); @@ -230,13 +233,18 @@ public class MergeCommand extends GitCommand { headCommit.getId(), srcCommit.getId() }, MergeStatus.FAILED, mergeStrategy, lowLevelResults, failingPaths, null); - } else + } else { + String mergeMessageWithConflicts = new MergeMessageFormatter() + .formatWithConflicts(mergeMessage, + unmergedPaths); + repo.writeMergeCommitMsg(mergeMessageWithConflicts); return new MergeResult(null, merger.getBaseCommit(0, 1), new ObjectId[] { headCommit.getId(), srcCommit.getId() }, MergeStatus.CONFLICTING, mergeStrategy, lowLevelResults, null); + } } } } catch (IOException e) { -- cgit v1.2.3