Browse Source

pgm: Handle exceptions in RevParse 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: Iae510d8c6af9acd587822a28ad48eab0b2a96ccd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.4
Matthias Sohn 6 years ago
parent
commit
795c265c11
  1. 11
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java

11
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java

@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -69,12 +70,13 @@ class RevParse extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
protected void run() {
try {
if (all) {
for (Ref r : db.getRefDatabase().getRefs()) {
ObjectId objectId = r.getObjectId();
// getRefs skips dangling symrefs, so objectId should never be
// null.
// getRefs skips dangling symrefs, so objectId should never
// be null.
if (objectId == null) {
throw new NullPointerException();
}
@ -91,5 +93,8 @@ class RevParse extends TextBuiltin {
outw.println(o.name());
}
}
} catch (IOException | CmdLineException e) {
throw die(e.getMessage(), e);
}
}
}

Loading…
Cancel
Save