/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { if (!prefix.isEmpty() && prefix.charAt(prefix.length() - 1) != '/') { return new HashMap<>(0); } Ref src = bootstrap.exactRef(txnCommitted); Scanner.Result c = refs; if (c == null || !c.refTreeId.equals(idOf(src))) { c = Scanner.scanRefTree(repo, src, prefix, true); if (prefix.isEmpty()) { refs = c; } } return new RefMap(prefix, RefList.<Ref> emptyList(), c.all, c.sym); }
/** {@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); }
(function () { var instCount = 0; self.RefMap = function () { instCount ++; var propName = '__RefMap' + instCount + '__'; this.has = function (o) { return propName in o; }; this.set = function (o) { o[propName] = true; } this.remove = function (o) { delete o[propName]; } } }()); //then use it like var myRefMap = new RefMap();
return new RefMap(prefix, packed, upcast(loose), symbolic.toRefList());
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = read(); RefList<Ref> packed = RefList.emptyList(); RefList<Ref> loose = curr.ids; RefList.Builder<Ref> sym = new RefList.Builder<>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { Ref ref = curr.sym.get(idx); String name = ref.getName(); ref = resolve(ref, 0, loose); if (ref != null && ref.getObjectId() != null) { sym.add(ref); } else { // A broken symbolic reference, we have to drop it from the // collections the client is about to receive. Should be a // rare occurrence so pay a copy penalty. int toRemove = loose.find(name); if (0 <= toRemove) loose = loose.remove(toRemove); } } return new RefMap(prefix, packed, loose, sym.toRefList()); }
@Override public Map<String, Ref> getRefs(String prefix) throws IOException { if (!prefix.isEmpty() && prefix.charAt(prefix.length() - 1) != '/') { return new HashMap<>(0); } Ref src = bootstrap.exactRef(txnCommitted); Scanner.Result c = refs; if (c == null || !c.refTreeId.equals(idOf(src))) { c = Scanner.scanRefTree(repo, src, prefix, true); if (prefix.isEmpty()) { refs = c; } } return new RefMap(prefix, RefList.<Ref> emptyList(), c.all, c.sym); }
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { if (!prefix.isEmpty() && prefix.charAt(prefix.length() - 1) != '/') { return new HashMap<>(0); } Ref src = bootstrap.exactRef(txnCommitted); Scanner.Result c = refs; if (c == null || !c.refTreeId.equals(idOf(src))) { c = Scanner.scanRefTree(repo, src, prefix, true); if (prefix.isEmpty()) { refs = c; } } return new RefMap(prefix, RefList.<Ref> emptyList(), c.all, c.sym); }
/** {@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); }
return new RefMap(prefix, packed, upcast(loose), symbolic.toRefList());
return new RefMap(prefix, packed, upcast(loose), symbolic.toRefList());
@Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = readRefs(); RefList<DhtRef> packed = RefList.emptyList(); RefList<DhtRef> loose = curr.ids; RefList.Builder<DhtRef> sym = new RefList.Builder<DhtRef>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { DhtRef ref = curr.sym.get(idx); String name = ref.getName(); ref = resolve(ref, 0, loose); if (ref != null && ref.getObjectId() != null) { sym.add(ref); } else { // A broken symbolic reference, we have to drop it from the // collections the client is about to receive. Should be a // rare occurrence so pay a copy penalty. int toRemove = loose.find(name); if (0 <= toRemove) loose = loose.remove(toRemove); } } return new RefMap(prefix, packed, loose, sym.toRefList()); }
@Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = read(); RefList<Ref> packed = RefList.emptyList(); RefList<Ref> loose = curr.ids; RefList.Builder<Ref> sym = new RefList.Builder<Ref>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { Ref ref = curr.sym.get(idx); String name = ref.getName(); ref = resolve(ref, 0, loose); if (ref != null && ref.getObjectId() != null) { sym.add(ref); } else { // A broken symbolic reference, we have to drop it from the // collections the client is about to receive. Should be a // rare occurrence so pay a copy penalty. int toRemove = loose.find(name); if (0 <= toRemove) loose = loose.remove(toRemove); } } return new RefMap(prefix, packed, loose, sym.toRefList()); }
@Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = readRefs(); RefList<DhtRef> packed = RefList.emptyList(); RefList<DhtRef> loose = curr.ids; RefList.Builder<DhtRef> sym = new RefList.Builder<DhtRef>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { DhtRef ref = curr.sym.get(idx); String name = ref.getName(); ref = resolve(ref, 0, loose); if (ref != null && ref.getObjectId() != null) { sym.add(ref); } else { // A broken symbolic reference, we have to drop it from the // collections the client is about to receive. Should be a // rare occurrence so pay a copy penalty. int toRemove = loose.find(name); if (0 <= toRemove) loose = loose.remove(toRemove); } } return new RefMap(prefix, packed, loose, sym.toRefList()); }
/** {@inheritDoc} */ @Override public Map<String, Ref> getRefs(String prefix) throws IOException { RefCache curr = read(); RefList<Ref> packed = RefList.emptyList(); RefList<Ref> loose = curr.ids; RefList.Builder<Ref> sym = new RefList.Builder<>(curr.sym.size()); for (int idx = 0; idx < curr.sym.size(); idx++) { Ref ref = curr.sym.get(idx); String name = ref.getName(); ref = resolve(ref, 0, loose); if (ref != null && ref.getObjectId() != null) { sym.add(ref); } else { // A broken symbolic reference, we have to drop it from the // collections the client is about to receive. Should be a // rare occurrence so pay a copy penalty. int toRemove = loose.find(name); if (0 <= toRemove) loose = loose.remove(toRemove); } } return new RefMap(prefix, packed, loose, sym.toRefList()); }