]> source.dussan.org Git - jgit.git/commitdiff
pgm: Handle IOException in MergeBase command 38/135438/2
authorMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Jan 2019 20:49:21 +0000 (21:49 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 20 Jan 2019 23:54:15 +0000 (00:54 +0100)
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: I5f198f71adfbb43ec1af26285658a5d5bdfa1904
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/MergeBase.java

index 6842d8ddbfc0b3c34ff131c38d9348c518718bc9..22d33582f5df031838401622255e8dfdb26e4eb8 100644 (file)
@@ -44,6 +44,7 @@
 
 package org.eclipse.jgit.pgm;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -67,16 +68,20 @@ class MergeBase extends TextBuiltin {
 
        /** {@inheritDoc} */
        @Override
-       protected void run() throws Exception {
-               for (RevCommit c : commits)
-                       argWalk.markStart(c);
-               argWalk.setRevFilter(RevFilter.MERGE_BASE);
-               int max = all ? Integer.MAX_VALUE : 1;
-               while (max-- > 0) {
-                       final RevCommit b = argWalk.next();
-                       if (b == null)
-                               break;
-                       outw.println(b.getId().name());
+       protected void run() {
+               try {
+                       for (RevCommit c : commits)
+                               argWalk.markStart(c);
+                       argWalk.setRevFilter(RevFilter.MERGE_BASE);
+                       int max = all ? Integer.MAX_VALUE : 1;
+                       while (max-- > 0) {
+                               final RevCommit b = argWalk.next();
+                               if (b == null)
+                                       break;
+                               outw.println(b.getId().name());
+                       }
+               } catch (IOException e) {
+                       throw die(e.getMessage(), e);
                }
        }
 }