package org.eclipse.jgit.pgm;
-import static org.eclipse.jgit.lib.RefDatabase.ALL;
-
import java.util.ArrayList;
import java.util.List;
@Override
protected void run() throws Exception {
if (all) {
- List<Ref> allRefs = db.getRefDatabase().getRefsByPrefix(ALL);
+ List<Ref> allRefs = db.getRefDatabase().getAllRefs();
for (final Ref r : allRefs) {
ObjectId objectId = r.getObjectId();
// getRefs skips dangling symrefs, so objectId should never be
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;
walk.setRevFilter(AndRevFilter.create(revLimiter));
if (all) {
- List<Ref> refs =
- db.getRefDatabase().getRefsByPrefix(RefDatabase.ALL);
+ List<Ref> refs = db.getRefDatabase().getAllRefs();
for (Ref a : refs) {
ObjectId oid = a.getPeeledObjectId();
if (oid == null)
package org.eclipse.jgit.pgm;
-import static org.eclipse.jgit.lib.RefDatabase.ALL;
-
import java.io.IOException;
import java.util.List;
}
private Iterable<Ref> getSortedRefs() throws Exception {
- List<Ref> all = db.getRefDatabase().getRefsByPrefix(ALL);
+ List<Ref> all = db.getRefDatabase().getAllRefs();
// TODO(jrn) check if we can reintroduce fast-path by e.g. implementing
// SortedList
return RefComparator.sort(all);
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;
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
- if (!really && !db.getRefDatabase().getRefsByPrefix(ALL).isEmpty()) {
+ if (!really && !db.getRefDatabase().getAllRefs().isEmpty()) {
File directory = db.getDirectory();
String absolutePath = directory == null ? "null" //$NON-NLS-1$
: directory.getAbsolutePath();
private void deleteAllRefs() throws Exception {
final RevWalk rw = new RevWalk(db);
- List<Ref> refs = db.getRefDatabase().getRefsByPrefix(ALL);
- for (final Ref r : refs) {
+ for (Ref r : db.getRefDatabase().getAllRefs()) {
if (Constants.HEAD.equals(r.getName()))
continue;
final RefUpdate u = db.updateRef(r.getName());
head));
}
- for (Ref r : refdb.getRefsByPrefix(RefDatabase.ALL)) {
+ for (Ref r : refdb.getAllRefs()) {
if (r.getName().equals(txnCommitted) || r.getName().equals(HEAD)
|| r.getName().startsWith(txnNamespace)) {
continue;
*/
package org.eclipse.jgit.api;
-import static org.eclipse.jgit.lib.RefDatabase.ALL;
-
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
* the references could not be accessed
*/
public LogCommand all() throws IOException {
- List<Ref> refs = getRepository().getRefDatabase().getRefsByPrefix(ALL);
- for (Ref ref : refs) {
+ for (Ref ref : getRepository().getRefDatabase().getAllRefs()) {
if(!ref.isPeeled())
ref = getRepository().peel(ref);
}
private Collection<Ref> getAllRefs() throws IOException {
- Collection<Ref> refs = refdb.getRefsByPrefix(RefDatabase.ALL);
+ Collection<Ref> refs = refdb.getAllRefs();
List<Ref> addl = refdb.getAdditionalRefs();
if (!addl.isEmpty()) {
List<Ref> all = new ArrayList<>(refs.size() + addl.size());
*/
private Collection<Ref> getAllRefs() throws IOException {
RefDatabase refdb = repo.getRefDatabase();
- Collection<Ref> refs = refdb.getRefsByPrefix(RefDatabase.ALL);
+ Collection<Ref> refs = refdb.getAllRefs();
List<Ref> addl = refdb.getAdditionalRefs();
if (!addl.isEmpty()) {
List<Ref> all = new ArrayList<>(refs.size() + addl.size());
}
RefDatabase refDb = repo.getRefDatabase();
- for (Ref r : refDb.getRefsByPrefix(RefDatabase.ALL)) {
+ for (Ref r : refDb.getAllRefs()) {
Storage storage = r.getStorage();
if (storage == Storage.LOOSE || storage == Storage.LOOSE_PACKED)
ret.numberOfLooseRefs++;
return Collections.unmodifiableList(result);
}
+ /**
+ * 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);
+ }
+
/**
* Get the additional reference-like entities from the repository.
* <p>
package org.eclipse.jgit.transport;
-import static org.eclipse.jgit.lib.RefDatabase.ALL;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
private void markReachable(final Set<ObjectId> have, final int maxTime)
throws IOException {
- for (Ref r : local.getRefDatabase().getRefsByPrefix(ALL)) {
+ for (Ref r : local.getRefDatabase().getAllRefs()) {
ObjectId id = r.getPeeledObjectId();
if (id == null)
id = r.getObjectId();
package org.eclipse.jgit.transport;
-import static org.eclipse.jgit.lib.RefDatabase.ALL;
-
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
List<Ref> localRefs;
try {
- localRefs = transport.local.getRefDatabase()
- .getRefsByPrefix(ALL);
+ localRefs = transport.local.getRefDatabase().getAllRefs();
} catch (IOException e) {
throw new TransportException(transport.uri, e.getMessage(), e);
}
package org.eclipse.jgit.transport;
import static org.eclipse.jgit.lib.Constants.CHARSET;
-import static org.eclipse.jgit.lib.RefDatabase.ALL;
import java.io.BufferedReader;
import java.io.IOException;
private static Collection<RefSpec> expandPushWildcardsFor(
final Repository db, final Collection<RefSpec> specs)
throws IOException {
- final List<Ref> localRefs = db.getRefDatabase().getRefsByPrefix(ALL);
+ final List<Ref> localRefs = db.getRefDatabase().getAllRefs();
final Collection<RefSpec> procRefs = new LinkedHashSet<>();
for (final RefSpec spec : specs) {
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.AsyncRevObjectQueue;
import org.eclipse.jgit.revwalk.BitmapWalker;
private Map<String, Ref> getAdvertisedOrDefaultRefs() throws IOException {
if (refs == null)
- setAdvertisedRefs(db.getRefDatabase().getRefs(RefDatabase.ALL));
+ setAdvertisedRefs(db.getRefDatabase().getRefs(ALL));
return refs;
}
else if (!wants.isEmpty()) {
Set<ObjectId> refIds =
refIdSet(up.getRepository().getRefDatabase()
- .getRefsByPrefix(ALL));
+ .getAllRefs());
for (ObjectId obj : wants) {
if (!refIds.contains(obj))
throw new WantNotValidException(obj);
public void checkWants(UploadPack up, List<ObjectId> wants)
throws PackProtocolException, IOException {
checkNotAdvertisedWants(up, wants,
- refIdSet(up.getRepository().getRefDatabase()
- .getRefsByPrefix(ALL)));
+ refIdSet(up.getRepository().getRefDatabase().getAllRefs()));
}
}
package org.eclipse.jgit.transport;
-import static org.eclipse.jgit.lib.RefDatabase.ALL;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
private void markLocalRefsComplete(final Set<ObjectId> have) throws TransportException {
List<Ref> refs;
try {
- refs = local.getRefDatabase().getRefsByPrefix(ALL);
+ refs = local.getRefDatabase().getAllRefs();
} catch (IOException e) {
throw new TransportException(e.getMessage(), e);
}