String name() { return rc.getRef().getName(); }
/** * Whether the current reference was deleted. * * @return {@code true} if the current reference was deleted. */ public boolean wasDeleted() { Ref r = getRef(); return r.getStorage() == Ref.Storage.NEW && r.getObjectId() == null; }
/** {@inheritDoc} */ @Override public List<Ref> getRefsByPrefix(String prefix) throws IOException { List<Ref> all = new ArrayList<>(); lock.lock(); try { Reftable table = reader(); try (RefCursor rc = ALL.equals(prefix) ? table.allRefs() : table.seekRefsWithPrefix(prefix)) { while (rc.next()) { Ref ref = table.resolve(rc.getRef()); if (ref != null && ref.getObjectId() != null) { all.add(ref); } } } } finally { lock.unlock(); } return Collections.unmodifiableList(all); }
/** * Lookup a reference, or null if not found. * * @param refName * reference name to find. * @return the reference, or {@code null} if not found. * @throws java.io.IOException * if references cannot be read. */ @Nullable public Ref exactRef(String refName) throws IOException { try (RefCursor rc = seekRef(refName)) { return rc.next() ? rc.getRef() : null; } }
private void mergeRefs(MergedReftable mr) throws IOException { try (RefCursor rc = mr.allRefs()) { while (rc.next()) { writer.writeRef(rc.getRef(), rc.getUpdateIndex()); } } }
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefList.Builder<Ref> all = new RefList.Builder<>(); lock.lock(); try { Reftable table = reader(); try (RefCursor rc = ALL.equals(prefix) ? table.allRefs() : (prefix.endsWith("/") ? table.seekRefsWithPrefix(prefix) //$NON-NLS-1$ : table.seekRef(prefix))) { while (rc.next()) { Ref ref = table.resolve(rc.getRef()); if (ref != null && ref.getObjectId() != null) { all.add(ref); } } } } finally { lock.unlock(); } RefList<Ref> none = RefList.emptyList(); return new RefMap(prefix, all.toRefList(), none, none); }
@Override public boolean next() throws IOException { for (;;) { RefQueueEntry t = poll(); if (t == null) { return false; } ref = t.rc.getRef(); updateIndex = t.rc.getUpdateIndex(); boolean include = includeDeletes || !t.rc.wasDeleted(); add(t); skipShadowedRefs(ref.getName()); if (include) { return true; } } }
String name() { return rc.getRef().getName(); }
/** * Whether the current reference was deleted. * * @return {@code true} if the current reference was deleted. */ public boolean wasDeleted() { Ref r = getRef(); return r.getStorage() == Ref.Storage.NEW && r.getObjectId() == null; }
/** {@inheritDoc} */ @Override public List<Ref> getRefsByPrefix(String prefix) throws IOException { List<Ref> all = new ArrayList<>(); lock.lock(); try { Reftable table = reader(); try (RefCursor rc = ALL.equals(prefix) ? table.allRefs() : table.seekRefsWithPrefix(prefix)) { while (rc.next()) { Ref ref = table.resolve(rc.getRef()); if (ref != null && ref.getObjectId() != null) { all.add(ref); } } } } finally { lock.unlock(); } return Collections.unmodifiableList(all); }
/** * Lookup a reference, or null if not found. * * @param refName * reference name to find. * @return the reference, or {@code null} if not found. * @throws java.io.IOException * if references cannot be read. */ @Nullable public Ref exactRef(String refName) throws IOException { try (RefCursor rc = seekRef(refName)) { return rc.next() ? rc.getRef() : null; } }
private void mergeRefs(MergedReftable mr) throws IOException { try (RefCursor rc = mr.allRefs()) { while (rc.next()) { writer.writeRef(rc.getRef(), rc.getUpdateIndex()); } } }
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefList.Builder<Ref> all = new RefList.Builder<>(); lock.lock(); try { Reftable table = reader(); try (RefCursor rc = ALL.equals(prefix) ? table.allRefs() : (prefix.endsWith("/") ? table.seekRefsWithPrefix(prefix) //$NON-NLS-1$ : table.seekRef(prefix))) { while (rc.next()) { Ref ref = table.resolve(rc.getRef()); if (ref != null && ref.getObjectId() != null) { all.add(ref); } } } } finally { lock.unlock(); } RefList<Ref> none = RefList.emptyList(); return new RefMap(prefix, all.toRefList(), none, none); }
@Override public boolean next() throws IOException { for (;;) { RefQueueEntry t = poll(); if (t == null) { return false; } ref = t.rc.getRef(); updateIndex = t.rc.getUpdateIndex(); boolean include = includeDeletes || !t.rc.wasDeleted(); add(t); skipShadowedRefs(ref.getName()); if (include) { return true; } } }