Kaynağa Gözat

pgm: Handle exceptions in Diff 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: Iba0e4338381519dc55c2892d95181ddfb881adf2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v5.3.0.201903061415-rc1
Matthias Sohn 5 yıl önce
ebeveyn
işleme
a6212392d5

+ 4
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java Dosyayı Görüntüle

@@ -62,6 +62,7 @@ import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.diff.RenameDetector;
import org.eclipse.jgit.dircache.DirCacheIterator;
import org.eclipse.jgit.errors.RevisionSyntaxException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Repository;
@@ -177,7 +178,7 @@ class Diff extends TextBuiltin {

/** {@inheritDoc} */
@Override
protected void run() throws Exception {
protected void run() {
diffFmt.setRepository(db);
try {
if (cached) {
@@ -217,6 +218,8 @@ class Diff extends TextBuiltin {
diffFmt.format(oldTree, newTree);
diffFmt.flush();
}
} catch (RevisionSyntaxException | IOException e) {
throw die(e.getMessage(), e);
} finally {
diffFmt.close();
}

Loading…
İptal
Kaydet