aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-01-20 21:34:07 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-01-21 00:54:14 +0100
commit40562d7f5c53bf7b455e16120fcdd9f29ed9d5a7 (patch)
treededb464eb0108aacd7d83092742fed7893b59207 /org.eclipse.jgit.pgm/src
parent1978f180a213c6b6ad6cab95e1606a229889e08c (diff)
downloadjgit-40562d7f5c53bf7b455e16120fcdd9f29ed9d5a7.tar.gz
jgit-40562d7f5c53bf7b455e16120fcdd9f29ed9d5a7.zip
pgm: Handle exceptions in LsRemote command
This avoids we show a stacktrace on the console by default when this type of exception is thrown during the run method is executed. Change-Id: If7dd168f3e8d2b729f1eab48d4e95fe837bb7a33 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
index 2711c15729..d8412fcd63 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java
@@ -51,6 +51,7 @@ import java.util.TreeSet;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.LsRemoteCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Ref;
import org.kohsuke.args4j.Argument;
@@ -72,7 +73,7 @@ class LsRemote extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote)
.setTimeout(timeout).setHeads(heads).setTags(tags);
TreeSet<Ref> refs = new TreeSet<>(new Comparator<Ref>() {
@@ -82,11 +83,15 @@ class LsRemote extends TextBuiltin {
return r1.getName().compareTo(r2.getName());
}
});
- refs.addAll(command.call());
- for (Ref r : refs) {
- show(r.getObjectId(), r.getName());
- if (r.getPeeledObjectId() != null)
- show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
+ try {
+ refs.addAll(command.call());
+ for (Ref r : refs) {
+ show(r.getObjectId(), r.getName());
+ if (r.getPeeledObjectId() != null)
+ show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$
+ }
+ } catch (GitAPIException | IOException e) {
+ throw die(e.getMessage(), e);
}
}