pgm: Handle IOException in UploadPack 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: Ife1d8e88387a32de63b0ef31f45499babdbdde3c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2019-01-21 23:52:27 +01:00
parent 7d073c129c
commit 9bf8a1bf14
1 changed files with 9 additions and 8 deletions

View File

@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
@ -70,20 +71,20 @@ protected final boolean requiresRepository() {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
final org.eclipse.jgit.transport.UploadPack up;
protected void run() {
try {
FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED);
db = key.open(true /* must exist */);
org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack(
db);
if (0 <= timeout)
up.setTimeout(timeout);
up.upload(ins, outs, errs);
} catch (RepositoryNotFoundException notFound) {
throw die(MessageFormat.format(CLIText.get().notAGitRepository,
srcGitdir.getPath()));
} catch (IOException e) {
throw die(e.getMessage(), e);
}
up = new org.eclipse.jgit.transport.UploadPack(db);
if (0 <= timeout)
up.setTimeout(timeout);
up.upload(ins, outs, errs);
}
}