Browse Source

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
stable-5.4
Matthias Sohn 6 years ago
parent
commit
1978f180a2
  1. 6
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsFiles.java

6
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<String> 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);
}
}

Loading…
Cancel
Save