/** {@inheritDoc} */ @Override public Ref exactRef(String name) throws IOException { lock.lock(); try { Reftable table = reader(); Ref ref = table.exactRef(name); if (ref != null && ref.isSymbolic()) { return table.resolve(ref); } return ref; } finally { lock.unlock(); } }
private boolean checkExpected(Reftable table, List<ReceiveCommand> pending) throws IOException { for (ReceiveCommand cmd : pending) { if (!matchOld(cmd, table.exactRef(cmd.getRefName()))) { cmd.setResult(LOCK_FAILURE); if (isAtomic()) { ReceiveCommand.abort(pending); return false; } } } return true; }
private Ref resolve(Ref ref, int depth) throws IOException { if (!ref.isSymbolic()) { return ref; } Ref dst = ref.getTarget(); if (MAX_SYMBOLIC_REF_DEPTH <= depth) { return null; // claim it doesn't exist } dst = exactRef(dst.getName()); if (dst == null) { return ref; } dst = resolve(dst, depth + 1); if (dst == null) { return null; // claim it doesn't exist } return new SymbolicRef(ref.getName(), dst); }
/** {@inheritDoc} */ @Override public Ref exactRef(String name) throws IOException { lock.lock(); try { Reftable table = reader(); Ref ref = table.exactRef(name); if (ref != null && ref.isSymbolic()) { return table.resolve(ref); } return ref; } finally { lock.unlock(); } }
private boolean checkExpected(Reftable table, List<ReceiveCommand> pending) throws IOException { for (ReceiveCommand cmd : pending) { if (!matchOld(cmd, table.exactRef(cmd.getRefName()))) { cmd.setResult(LOCK_FAILURE); if (isAtomic()) { ReceiveCommand.abort(pending); return false; } } } return true; }
private Ref resolve(Ref ref, int depth) throws IOException { if (!ref.isSymbolic()) { return ref; } Ref dst = ref.getTarget(); if (MAX_SYMBOLIC_REF_DEPTH <= depth) { return null; // claim it doesn't exist } dst = exactRef(dst.getName()); if (dst == null) { return ref; } dst = resolve(dst, depth + 1); if (dst == null) { return null; // claim it doesn't exist } return new SymbolicRef(ref.getName(), dst); }