From 1978f180a213c6b6ad6cab95e1606a229889e08c Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 20 Jan 2019 21:32:21 +0100 Subject: [PATCH] pgm: Handle exceptions in LsFiles 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: I7d71e194f0a7e4180094a9b36dbb55dd90c9722e --- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java index dc13000d63..ef25844973 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java @@ -48,11 +48,13 @@ import static org.eclipse.jgit.lib.FileMode.GITLINK; import static org.eclipse.jgit.lib.FileMode.REGULAR_FILE; import static org.eclipse.jgit.lib.FileMode.SYMLINK; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.eclipse.jgit.dircache.DirCacheIterator; +import org.eclipse.jgit.errors.RevisionSyntaxException; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.ObjectId; @@ -72,7 +74,7 @@ class LsFiles extends TextBuiltin { private List paths = new ArrayList<>(); @Override - protected void run() throws Exception { + protected void run() { try (RevWalk rw = new RevWalk(db); TreeWalk tw = new TreeWalk(db)) { final ObjectId head = db.resolve(Constants.HEAD); @@ -96,6 +98,8 @@ class LsFiles extends TextBuiltin { QuotedString.GIT_PATH.quote(tw.getPathString())); } } + } catch (RevisionSyntaxException | IOException e) { + throw die(e.getMessage(), e); } } -- 2.39.5