Browse Source

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>
stable-5.4
Matthias Sohn 6 years ago
parent
commit
9bf8a1bf14
  1. 17
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java

17
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java

@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm; package org.eclipse.jgit.pgm;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.text.MessageFormat; import java.text.MessageFormat;
import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.errors.RepositoryNotFoundException;
@ -70,20 +71,20 @@ class UploadPack extends TextBuiltin {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected void run() throws Exception { protected void run() {
final org.eclipse.jgit.transport.UploadPack up;
try { try {
FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED); FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED);
db = key.open(true /* must exist */); 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) { } catch (RepositoryNotFoundException notFound) {
throw die(MessageFormat.format(CLIText.get().notAGitRepository, throw die(MessageFormat.format(CLIText.get().notAGitRepository,
srcGitdir.getPath())); 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);
} }
} }

Loading…
Cancel
Save