From e5511f2fbbf363e3ae78927120a86c380d6566d9 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 21 Jan 2019 23:41:37 +0100 Subject: [PATCH] pgm: Handle exceptions in Show 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: I1c6cc5ecdc44b81e5f3f9b7dc64c3653de5475ba Signed-off-by: Matthias Sohn --- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java index 89a15fe4d..fe2c0d5c5 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java @@ -59,6 +59,7 @@ import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.MissingObjectException; +import org.eclipse.jgit.errors.RevisionSyntaxException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.ObjectId; @@ -175,7 +176,7 @@ protected void init(Repository repository, String gitDir) { /** {@inheritDoc} */ @SuppressWarnings("boxing") @Override - protected void run() throws Exception { + protected void run() { diffFmt.setRepository(db); try { diffFmt.setPathFilter(pathFilter); @@ -224,6 +225,8 @@ protected void run() throws Exception { obj.getType())); } } + } catch (RevisionSyntaxException | IOException e) { + throw die(e.getMessage(), e); } finally { diffFmt.close(); } @@ -273,7 +276,7 @@ private void show(RevTree obj) throws MissingObjectException, } } - private void show(RevWalk rw, RevCommit c) throws Exception { + private void show(RevWalk rw, RevCommit c) throws IOException { char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2]; outw.print(CLIText.get().commitLabel);