aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-01-20 01:27:57 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-01-20 01:27:57 +0100
commit3b059f6ff626afe59a4c2b9f7d14237e42b02b13 (patch)
tree98d47c901f1f4bcd515e89213f79338231852541 /org.eclipse.jgit.pgm
parent5482980e4f28472061b3d66be3e362f175d28dc3 (diff)
downloadjgit-3b059f6ff626afe59a4c2b9f7d14237e42b02b13.tar.gz
jgit-3b059f6ff626afe59a4c2b9f7d14237e42b02b13.zip
pgm: Handle exceptions in Commit 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: Idf5325bcc235fbcf4418239a1d49572409576a7d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
index 00d2d100d2..ebbb932ac4 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Commit.java
@@ -37,15 +37,14 @@
*/
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
-import org.eclipse.jgit.api.errors.NoHeadException;
-import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.pgm.internal.CLIText;
@@ -87,8 +86,7 @@ class Commit extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws NoHeadException, NoMessageException,
- ConcurrentRefUpdateException, JGitInternalException, Exception {
+ protected void run() {
try (Git git = new Git(db)) {
CommitCommand commitCmd = git.commit();
if (author != null)
@@ -119,7 +117,7 @@ class Commit extends TextBuiltin {
RevCommit commit;
try {
commit = commitCmd.call();
- } catch (JGitInternalException e) {
+ } catch (JGitInternalException | GitAPIException e) {
throw die(e.getMessage(), e);
}
@@ -133,6 +131,8 @@ class Commit extends TextBuiltin {
}
outw.println("[" + branchName + " " + commit.name() + "] " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ commit.getShortMessage());
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
}
}