summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorColby Ranger <cranger@google.com>2013-10-07 10:25:28 -0700
committerColby Ranger <cranger@google.com>2013-10-07 11:32:54 -0700
commit5218f7b33afc02bcd0029767e867222ddc000b09 (patch)
tree00bd1fcde2c54c1e6b6fa89c8b54b64a718a9eb3 /org.eclipse.jgit.pgm/src
parent7995d87713c1fed181643c2a6cf30ed464917e9a (diff)
downloadjgit-5218f7b33afc02bcd0029767e867222ddc000b09.tar.gz
jgit-5218f7b33afc02bcd0029767e867222ddc000b09.zip
Propagate IOException where possible when getting refs.
Currently, Repository.getAllRefs() and Repository.getTags() silently ignores an IOException and instead returns an empty map. Repository is a public API and as such cannot be changed until the next major revision change. Where possible, update the internal jgit APIs to use the RefDatabase directly, since it propagates the error. Change-Id: I4e4537d8bd0fa772f388262684c5c4ca1929dc4c
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java9
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java6
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java7
5 files changed, 22 insertions, 8 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
index 969a8e0c08..0307a6073e 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Branch.java
@@ -43,6 +43,8 @@
package org.eclipse.jgit.pgm;
+import static org.eclipse.jgit.lib.RefDatabase.ALL;
+
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -175,7 +177,7 @@ class Branch extends TextBuiltin {
}
private void list() throws Exception {
- Map<String, Ref> refs = db.getAllRefs();
+ Map<String, Ref> refs = db.getRefDatabase().getRefs(ALL);
Ref head = refs.get(Constants.HEAD);
// This can happen if HEAD is stillborn
if (head != null) {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
index 674c202273..5530ac5c99 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
@@ -44,6 +44,8 @@
package org.eclipse.jgit.pgm;
+import static org.eclipse.jgit.lib.RefDatabase.ALL;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -64,7 +66,7 @@ class RevParse extends TextBuiltin {
@Override
protected void run() throws Exception {
if (all) {
- Map<String, Ref> allRefs = db.getAllRefs();
+ Map<String, Ref> allRefs = db.getRefDatabase().getRefs(ALL);
for (final Ref r : allRefs.values())
outw.println(r.getObjectId().name());
} else {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java
index 4327403690..847bf7fc1a 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java
@@ -47,6 +47,7 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
+import java.util.Map;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@@ -55,6 +56,7 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.pgm.internal.CLIText;
import org.eclipse.jgit.pgm.opt.PathTreeFilterHandler;
import org.eclipse.jgit.revwalk.FollowFilter;
@@ -164,8 +166,10 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
else if (revLimiter.size() > 1)
walk.setRevFilter(AndRevFilter.create(revLimiter));
- if (all)
- for (Ref a : db.getAllRefs().values()) {
+ if (all) {
+ Map<String, Ref> refs =
+ db.getRefDatabase().getRefs(RefDatabase.ALL);
+ for (Ref a : refs.values()) {
ObjectId oid = a.getPeeledObjectId();
if (oid == null)
oid = a.getObjectId();
@@ -175,6 +179,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
// Ignore all refs which are not commits
}
}
+ }
if (commits.isEmpty()) {
final ObjectId head = db.resolve(Constants.HEAD);
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
index 203c92d4a5..e9d9df6a19 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java
@@ -45,6 +45,8 @@
package org.eclipse.jgit.pgm;
+import static org.eclipse.jgit.lib.RefDatabase.ALL;
+
import java.io.IOException;
import java.util.Map;
import java.util.SortedMap;
@@ -65,8 +67,8 @@ class ShowRef extends TextBuiltin {
}
}
- private Iterable<Ref> getSortedRefs() {
- Map<String, Ref> all = db.getAllRefs();
+ private Iterable<Ref> getSortedRefs() throws Exception {
+ Map<String, Ref> all = db.getRefDatabase().getRefs(ALL);
if (all instanceof RefMap
|| (all instanceof SortedMap && ((SortedMap) all).comparator() == null))
return all.values();
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
index df59bbe686..cd0236cc04 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java
@@ -43,6 +43,8 @@
package org.eclipse.jgit.pgm.debug;
+import static org.eclipse.jgit.lib.RefDatabase.ALL;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -114,7 +116,7 @@ class RebuildCommitGraph extends TextBuiltin {
@Override
protected void run() throws Exception {
- if (!really && !db.getAllRefs().isEmpty()) {
+ if (!really && !db.getRefDatabase().getRefs(ALL).isEmpty()) {
System.err.println(
MessageFormat.format(CLIText.get().fatalThisProgramWillDestroyTheRepository
, db.getDirectory().getAbsolutePath(), REALLY));
@@ -241,7 +243,8 @@ class RebuildCommitGraph extends TextBuiltin {
private void deleteAllRefs() throws Exception {
final RevWalk rw = new RevWalk(db);
- for (final Ref r : db.getAllRefs().values()) {
+ Map<String, Ref> refs = db.getRefDatabase().getRefs(ALL);
+ for (final Ref r : refs.values()) {
if (Constants.HEAD.equals(r.getName()))
continue;
final RefUpdate u = db.updateRef(r.getName());