diff options
author | Ned Twigg <ned.twigg@diffplug.com> | 2016-03-18 02:37:58 -0700 |
---|---|---|
committer | Ned Twigg <ned.twigg@diffplug.com> | 2017-10-01 00:07:26 -0400 |
commit | f333c7496b1352801dddc7dfe488efbcfd2ca4a8 (patch) | |
tree | 36a058769d156afe8004974a14cfa830157d0916 /org.eclipse.jgit.pgm/src/org | |
parent | a0a8a6a3e48d4f872e92dfed4ee6b40a5a177a42 (diff) | |
download | jgit-f333c7496b1352801dddc7dfe488efbcfd2ca4a8.tar.gz jgit-f333c7496b1352801dddc7dfe488efbcfd2ca4a8.zip |
Checkout now reports failures through exceptions.
Checkout sometimes throws an exception, and
other times it writes an error message to outw
and returns normally, even though the command
failed. This commit now reports all failures
through a die() exception.
Change-Id: I038a5d976d95020fea3faac68e9178f923c25b28
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java index b5cf56e938..2af1eca807 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java @@ -122,17 +122,21 @@ class Checkout extends TextBuiltin { CLIText.get().switchedToBranch, Repository.shortenRefName(ref.getName()))); } catch (RefNotFoundException e) { - outw.println(MessageFormat.format( - CLIText.get().pathspecDidNotMatch, - name)); + throw die(MessageFormat + .format(CLIText.get().pathspecDidNotMatch, name), e); } catch (RefAlreadyExistsException e) { - throw die(MessageFormat.format(CLIText.get().branchAlreadyExists, - name)); + throw die(MessageFormat + .format(CLIText.get().branchAlreadyExists, name)); } catch (CheckoutConflictException e) { - outw.println(CLIText.get().checkoutConflict); - for (String path : e.getConflictingPaths()) - outw.println(MessageFormat.format( + StringBuilder builder = new StringBuilder(); + builder.append(CLIText.get().checkoutConflict); + builder.append(System.lineSeparator()); + for (String path : e.getConflictingPaths()) { + builder.append(MessageFormat.format( CLIText.get().checkoutConflictPathLine, path)); + builder.append(System.lineSeparator()); + } + throw die(builder.toString(), e); } } } |