Browse Source

pgm: Handle GitAPIException in Gc 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: I4d3c04b27727762870d3135228768aae177ea3fc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.4
Matthias Sohn 6 years ago
parent
commit
e65497ad09
  1. 7
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java

7
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java

@ -44,6 +44,7 @@
package org.eclipse.jgit.pgm;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.TextProgressMonitor;
import org.kohsuke.args4j.Option;
@ -60,11 +61,15 @@ class Gc extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
protected void run() {
Git git = Git.wrap(db);
try {
git.gc().setAggressive(aggressive)
.setPreserveOldPacks(preserveOldPacks)
.setPrunePreserved(prunePreserved)
.setProgressMonitor(new TextProgressMonitor(errw)).call();
} catch (GitAPIException e) {
throw die(e.getMessage(), e);
}
}
}

Loading…
Cancel
Save