]> source.dussan.org Git - jgit.git/commitdiff
pgm: Handle NoWorkTreeException and IOException in Blame command 99/135199/3
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 16 Jan 2019 17:04:55 +0000 (18:04 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Jan 2019 00:08:26 +0000 (01:08 +0100)
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: I9290b057b004e9ee4137d968ba4f5759442aacb6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java

index 7337421c825ecda643f98feaf2442dc4120f6aba..3ea8fb2efc4f9558f0aff6c5f1e609b9e44c4324 100644 (file)
@@ -65,6 +65,7 @@ import org.eclipse.jgit.blame.BlameResult;
 import org.eclipse.jgit.diff.RawText;
 import org.eclipse.jgit.diff.RawTextComparator;
 import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.errors.NoWorkTreeException;
 import org.eclipse.jgit.lib.Constants;
 import org.eclipse.jgit.lib.ObjectReader;
 import org.eclipse.jgit.lib.PersonIdent;
@@ -134,7 +135,7 @@ class Blame extends TextBuiltin {
 
        /** {@inheritDoc} */
        @Override
-       protected void run() throws Exception {
+       protected void run() {
                if (file == null) {
                        if (revision == null)
                                throw die(CLIText.get().fileIsRequired);
@@ -244,6 +245,8 @@ class Blame extends TextBuiltin {
                                        outw.print('\n');
                                } while (++line < end && blame.getSourceCommit(line) == c);
                        }
+               } catch (NoWorkTreeException | IOException e) {
+                       throw die(e.getMessage(), e);
                }
        }