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>
tags/v5.3.0.201903061415-rc1
Matthias Sohn 5 years ago
parent
commit
9bf8a1bf14
1 changed files with 9 additions and 8 deletions
  1. 9
    8
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java

+ 9
- 8
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java 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 @@ class UploadPack extends TextBuiltin {

/** {@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);
}
}

Loading…
Cancel
Save