瀏覽代碼

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 年之前
父節點
當前提交
a6212392d5
共有 1 個檔案被更改,包括 4 行新增1 行删除
  1. 4
    1
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java

+ 4
- 1
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java 查看文件

@@ -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…
取消
儲存