diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties index eed05e89f..07d9c00c7 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/CLIText.properties @@ -65,7 +65,9 @@ jgitVersion=jgit version {0} lineFormat=# {0} listeningOn=Listening on {0} mergeConflict=CONFLICT(content): Merge conflict in {0} +mergeCheckoutConflict=error: Your local changes to the following files would be overwritten by merge: mergeFailed=Automatic merge failed; fix conflicts and then commit the result +mergeCheckoutFailed=Please, commit your changes or stash them before you can merge. mergeMadeBy=Merge made by the ''{0}'' strategy. mergedSquashed=Squash commit -- not updating HEAD\nAutomatic merge went well; stopped before committing as requested mergeWentWellStoppedBeforeCommitting=Automatic merge went well; stopped before committing as requested diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java index 64bd18e86..1f14fa272 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java @@ -133,8 +133,10 @@ public class CLIText extends TranslationBundle { /***/ public String jgitVersion; /***/ public String lineFormat; /***/ public String listeningOn; + /***/ public String mergeCheckoutConflict; /***/ public String mergeConflict; /***/ public String mergeFailed; + /***/ public String mergeCheckoutFailed; /***/ public String mergeMadeBy; /***/ public String mergedSquashed; /***/ public String mergeWentWellStoppedBeforeCommitting; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java index 97198259d..e25ac4f3e 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java @@ -51,6 +51,7 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.MergeCommand; import org.eclipse.jgit.api.MergeResult; import org.eclipse.jgit.api.MergeCommand.FastForwardMode; +import org.eclipse.jgit.api.errors.CheckoutConflictException; import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; @@ -119,7 +120,12 @@ class Merge extends TextBuiltin { mergeCmd.include(srcRef); else mergeCmd.include(src); - MergeResult result = mergeCmd.call(); + MergeResult result; + try { + result = mergeCmd.call(); + } catch (CheckoutConflictException e) { + result = new MergeResult(e.getConflictingPaths()); // CHECKOUT_CONFLICT + } switch (result.getMergeStatus()) { case ALREADY_UP_TO_DATE: @@ -134,6 +140,12 @@ class Merge extends TextBuiltin { .name())); outw.println(result.getMergeStatus().toString()); break; + case CHECKOUT_CONFLICT: + outw.println(CLIText.get().mergeCheckoutConflict); + for (String collidingPath : result.getCheckoutConflicts()) + outw.println("\t" + collidingPath); //$NON-NLS-1$ + outw.println(CLIText.get().mergeCheckoutFailed); + break; case CONFLICTING: for (String collidingPath : result.getConflicts().keySet()) outw.println(MessageFormat.format(CLIText.get().mergeConflict,