From d8fec824e4f81dbae5bb72046560452cd19b319d Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 21 Jan 2019 23:17:00 +0100 Subject: [PATCH] pgm: Handle exceptions in Reflog 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: Id25eb523c12c07cbd14e31edfb8b5d7ec9b3ccf3 Signed-off-by: Matthias Sohn --- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java index 6f4fcc248..410e88fde 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java @@ -42,10 +42,12 @@ */ package org.eclipse.jgit.pgm; +import java.io.IOException; import java.util.Collection; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ReflogCommand; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ReflogEntry; import org.eclipse.jgit.lib.Repository; @@ -59,7 +61,7 @@ class Reflog extends TextBuiltin { /** {@inheritDoc} */ @Override - protected void run() throws Exception { + protected void run() { try (Git git = new Git(db)) { ReflogCommand cmd = git.reflog(); if (ref != null) @@ -69,6 +71,8 @@ class Reflog extends TextBuiltin { for (ReflogEntry entry : entries) { outw.println(toString(entry, i++)); } + } catch (GitAPIException | IOException e) { + throw die(e.getMessage(), e); } }