/** * Test if any reference starts with {@code prefix} as a prefix. * * @param prefix * prefix to find. * @return {@code true} if at least one reference exists with prefix. * @throws java.io.IOException * if references cannot be read. */ public boolean hasRefsWithPrefix(String prefix) throws IOException { try (RefCursor rc = seekRefsWithPrefix(prefix)) { return rc.next(); } }
/** {@inheritDoc} */ @Override public RefCursor seekRefsWithPrefix(String prefix) throws IOException { MergedRefCursor m = new MergedRefCursor(); for (int i = 0; i < tables.length; i++) { m.add(new RefQueueEntry(tables[i].seekRefsWithPrefix(prefix), i)); } return m; }
/** {@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); }
/** {@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); }
/** * Test if any reference starts with {@code prefix} as a prefix. * * @param prefix * prefix to find. * @return {@code true} if at least one reference exists with prefix. * @throws java.io.IOException * if references cannot be read. */ public boolean hasRefsWithPrefix(String prefix) throws IOException { try (RefCursor rc = seekRefsWithPrefix(prefix)) { return rc.next(); } }
/** {@inheritDoc} */ @Override public RefCursor seekRefsWithPrefix(String prefix) throws IOException { MergedRefCursor m = new MergedRefCursor(); for (int i = 0; i < tables.length; i++) { m.add(new RefQueueEntry(tables[i].seekRefsWithPrefix(prefix), i)); } return m; }
/** {@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); }
/** {@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); }