diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-01-20 21:16:21 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-01-20 22:18:41 +0100 |
commit | e65497ad0913089d28c67ecd9dfaeede6725e84a (patch) | |
tree | 69ba77fbccfd533a2a9eaccb06119e01c65076d4 /org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm | |
parent | 8264135d7c0d6c19873444e57823b88c1a721e62 (diff) | |
download | jgit-e65497ad0913089d28c67ecd9dfaeede6725e84a.tar.gz jgit-e65497ad0913089d28c67ecd9dfaeede6725e84a.zip |
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>
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java index 56172f57c3..e65f0ec844 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Gc.java +++ b/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); - git.gc().setAggressive(aggressive) - .setPreserveOldPacks(preserveOldPacks) - .setPrunePreserved(prunePreserved) - .setProgressMonitor(new TextProgressMonitor(errw)).call(); + try { + git.gc().setAggressive(aggressive) + .setPreserveOldPacks(preserveOldPacks) + .setPrunePreserved(prunePreserved) + .setProgressMonitor(new TextProgressMonitor(errw)).call(); + } catch (GitAPIException e) { + throw die(e.getMessage(), e); + } } } |