Browse Source

pgm: Handle NoWorkTreeException and IOException in Blame 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: I9290b057b004e9ee4137d968ba4f5759442aacb6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.4
Matthias Sohn 6 years ago
parent
commit
2f94a26b17
  1. 5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java

5
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java

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

Loading…
Cancel
Save