summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevWalkTextBuiltin.java3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/ShowRef.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java2
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java51
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java5
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java2
14 files changed, 47 insertions, 37 deletions
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 a52954307e..21e37cd8c9 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
@@ -71,8 +71,7 @@ class RevParse extends TextBuiltin {
@Override
protected void run() throws Exception {
if (all) {
- List<Ref> allRefs = db.getRefDatabase().getAllRefs();
- for (final Ref r : allRefs) {
+ for (Ref r : db.getRefDatabase().getRefs()) {
ObjectId objectId = r.getObjectId();
// getRefs skips dangling symrefs, so objectId should never be
// null.
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 423887cc17..80161b4829 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
@@ -169,8 +169,7 @@ abstract class RevWalkTextBuiltin extends TextBuiltin {
walk.setRevFilter(AndRevFilter.create(revLimiter));
if (all) {
- List<Ref> refs = db.getRefDatabase().getAllRefs();
- for (Ref a : refs) {
+ for (Ref a : db.getRefDatabase().getRefs()) {
ObjectId oid = a.getPeeledObjectId();
if (oid == null)
oid = a.getObjectId();
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 f6384a2cea..9ce8347d91 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
@@ -65,7 +65,7 @@ class ShowRef extends TextBuiltin {
}
private Iterable<Ref> getSortedRefs() throws Exception {
- List<Ref> all = db.getRefDatabase().getAllRefs();
+ List<Ref> all = db.getRefDatabase().getRefs();
// TODO(jrn) check if we can reintroduce fast-path by e.g. implementing
// SortedList
return RefComparator.sort(all);
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 19d94eadef..42dea219f7 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
@@ -245,7 +245,7 @@ class RebuildCommitGraph extends TextBuiltin {
private void deleteAllRefs() throws Exception {
final RevWalk rw = new RevWalk(db);
- for (Ref r : db.getRefDatabase().getAllRefs()) {
+ for (Ref r : db.getRefDatabase().getRefs()) {
if (Constants.HEAD.equals(r.getName()))
continue;
final RefUpdate u = db.updateRef(r.getName());
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
index 6665ce7c1d..86092b27a5 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildRefTree.java
@@ -154,7 +154,7 @@ class RebuildRefTree extends TextBuiltin {
head));
}
- for (Ref r : refdb.getAllRefs()) {
+ for (Ref r : refdb.getRefs()) {
if (r.getName().equals(txnCommitted) || r.getName().equals(HEAD)
|| r.getName().startsWith(txnNamespace)) {
continue;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
index 73433c18b8..cdf8cdd8d7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/LogCommand.java
@@ -272,7 +272,7 @@ public class LogCommand extends GitCommand<Iterable<RevCommit>> {
* the references could not be accessed
*/
public LogCommand all() throws IOException {
- for (Ref ref : getRepository().getRefDatabase().getAllRefs()) {
+ for (Ref ref : getRepository().getRefDatabase().getRefs()) {
if(!ref.isPeeled())
ref = getRepository().peel(ref);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
index 30bcbf068b..ca11fb9265 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
@@ -403,7 +403,7 @@ public class DfsGarbageCollector {
}
private Collection<Ref> getAllRefs() throws IOException {
- Collection<Ref> refs = refdb.getAllRefs();
+ Collection<Ref> refs = refdb.getRefs();
List<Ref> addl = refdb.getAdditionalRefs();
if (!addl.isEmpty()) {
List<Ref> all = new ArrayList<>(refs.size() + addl.size());
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
index 1ea686e7cd..137a757311 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
@@ -1068,7 +1068,7 @@ public class GC {
*/
private Collection<Ref> getAllRefs() throws IOException {
RefDatabase refdb = repo.getRefDatabase();
- Collection<Ref> refs = refdb.getAllRefs();
+ Collection<Ref> refs = refdb.getRefs();
List<Ref> addl = refdb.getAdditionalRefs();
if (!addl.isEmpty()) {
List<Ref> all = new ArrayList<>(refs.size() + addl.size());
@@ -1376,7 +1376,7 @@ public class GC {
}
RefDatabase refDb = repo.getRefDatabase();
- for (Ref r : refDb.getAllRefs()) {
+ for (Ref r : refDb.getRefs()) {
Storage storage = r.getStorage();
if (storage == Storage.LOOSE || storage == Storage.LOOSE_PACKED)
ret.numberOfLooseRefs++;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
index 0ae14d1304..3170787dd9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
@@ -337,6 +337,29 @@ public abstract class RefDatabase {
}
/**
+ * Returns all refs.
+ * <p>
+ * This includes {@code HEAD}, branches under {@code ref/heads/}, tags
+ * under {@code refs/tags/}, etc. It does not include pseudo-refs like
+ * {@code FETCH_HEAD}; for those, see {@link #getAdditionalRefs}.
+ * <p>
+ * Symbolic references to a non-existent ref (for example,
+ * {@code HEAD} pointing to a branch yet to be born) are not included.
+ * <p>
+ * Callers interested in only a portion of the ref hierarchy can call
+ * {@link #getRefsByPrefix} instead.
+ *
+ * @return immutable list of all refs.
+ * @throws java.io.IOException
+ * the reference space cannot be accessed.
+ * @since 5.0
+ */
+ @NonNull
+ public List<Ref> getRefs() throws IOException {
+ return getRefsByPrefix(ALL);
+ }
+
+ /**
* Get a section of the reference namespace.
*
* @param prefix
@@ -357,7 +380,7 @@ public abstract class RefDatabase {
/**
* Returns refs whose names start with a given prefix.
* <p>
- * The default implementation uses {@link #getRefs}. Implementors of
+ * The default implementation uses {@link #getRefs(String)}. Implementors of
* {@link RefDatabase} should override this method directly if a better
* implementation is possible.
*
@@ -392,23 +415,13 @@ public abstract class RefDatabase {
}
/**
- * Returns all refs.
- * <p>
- * Callers interested in only a portion of the ref hierarchy can call
- * {@link #getRefsByPrefix} instead.
- *
- * @return immutable list of all refs.
- * @throws java.io.IOException
- * the reference space cannot be accessed.
- * @since 5.0
- */
- @NonNull
- public List<Ref> getAllRefs() throws IOException {
- return getRefsByPrefix(ALL);
- }
-
- /**
* Check if any refs exist in the ref database.
+ * <p>
+ * This uses the same definition of refs as {@link #getRefs()}. In
+ * particular, returns {@code false} in a new repository with no refs
+ * under {@code refs/} and {@code HEAD} pointing to a branch yet to be
+ * born, and returns {@code true} in a repository with no refs under
+ * {@code refs/} and a detached {@code HEAD} pointing to history.
*
* @return true if the database has refs.
* @throws java.io.IOException
@@ -416,7 +429,7 @@ public abstract class RefDatabase {
* @since 5.0
*/
public boolean hasRefs() throws IOException {
- return !getAllRefs().isEmpty();
+ return !getRefs().isEmpty();
}
/**
@@ -424,7 +437,7 @@ public abstract class RefDatabase {
* <p>
* The result list includes non-ref items such as MERGE_HEAD and
* FETCH_RESULT cast to be refs. The names of these refs are not returned by
- * <code>getRefs(ALL)</code> but are accepted by {@link #getRef(String)}
+ * <code>getRefs()</code> but are accepted by {@link #getRef(String)}
* and {@link #exactRef(String)}.
*
* @return a list of additional refs
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
index a88918e7a1..96329d1f18 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
@@ -437,7 +437,7 @@ public abstract class BasePackFetchConnection extends BasePackConnection
private void markReachable(final Set<ObjectId> have, final int maxTime)
throws IOException {
- for (Ref r : local.getRefDatabase().getAllRefs()) {
+ for (Ref r : local.getRefDatabase().getRefs()) {
ObjectId id = r.getPeeledObjectId();
if (id == null)
id = r.getObjectId();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
index 24f44cb460..7cf10e95be 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleFetchConnection.java
@@ -254,7 +254,7 @@ class BundleFetchConnection extends BaseFetchConnection {
List<Ref> localRefs;
try {
- localRefs = transport.local.getRefDatabase().getAllRefs();
+ localRefs = transport.local.getRefDatabase().getRefs();
} catch (IOException e) {
throw new TransportException(transport.uri, e.getMessage(), e);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
index 9ff5f7b91f..77a4d92ab3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java
@@ -688,7 +688,7 @@ public abstract class Transport implements AutoCloseable {
private static Collection<RefSpec> expandPushWildcardsFor(
final Repository db, final Collection<RefSpec> specs)
throws IOException {
- final List<Ref> localRefs = db.getRefDatabase().getAllRefs();
+ final List<Ref> localRefs = db.getRefDatabase().getRefs();
final Collection<RefSpec> procRefs = new LinkedHashSet<>();
for (final RefSpec spec : specs) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index 2a1b2492e6..b1832fd026 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -1581,8 +1581,7 @@ public class UploadPack {
new ReachableCommitTipRequestValidator().checkWants(up, wants);
else if (!wants.isEmpty()) {
Set<ObjectId> refIds =
- refIdSet(up.getRepository().getRefDatabase()
- .getAllRefs());
+ refIdSet(up.getRepository().getRefDatabase().getRefs());
for (ObjectId obj : wants) {
if (!refIds.contains(obj))
throw new WantNotValidException(obj);
@@ -1602,7 +1601,7 @@ public class UploadPack {
public void checkWants(UploadPack up, List<ObjectId> wants)
throws PackProtocolException, IOException {
checkNotAdvertisedWants(up, wants,
- refIdSet(up.getRepository().getRefDatabase().getAllRefs()));
+ refIdSet(up.getRepository().getRefDatabase().getRefs()));
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java
index c0ee28a2cd..b8f8d97beb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java
@@ -689,7 +689,7 @@ class WalkFetchConnection extends BaseFetchConnection {
private void markLocalRefsComplete(final Set<ObjectId> have) throws TransportException {
List<Ref> refs;
try {
- refs = local.getRefDatabase().getAllRefs();
+ refs = local.getRefDatabase().getRefs();
} catch (IOException e) {
throw new TransportException(e.getMessage(), e);
}