Browse Source

dfs: use RefDatabase API for exactRef in ReftableBatchRefUpdate

This removes one use of DFS specific code in this class.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I3ef6a4b98357cc6dc480892244ddc51d2fd751a2
next
Han-Wen Nienhuys 5 years ago
parent
commit
434e6c732a
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/ReftableBatchRefUpdate.java

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/ReftableBatchRefUpdate.java

@ -141,8 +141,7 @@ public class ReftableBatchRefUpdate extends BatchRefUpdate {
lock.lock(); lock.lock();
try { try {
Reftable table = refdb.reader(); if (!checkExpected(pending)) {
if (!checkExpected(table, pending)) {
return; return;
} }
if (!checkConflicting(pending)) { if (!checkConflicting(pending)) {
@ -236,10 +235,10 @@ public class ReftableBatchRefUpdate extends BatchRefUpdate {
return ok; return ok;
} }
private boolean checkExpected(Reftable table, List<ReceiveCommand> pending) private boolean checkExpected(List<ReceiveCommand> pending)
throws IOException { throws IOException {
for (ReceiveCommand cmd : pending) { for (ReceiveCommand cmd : pending) {
if (!matchOld(cmd, table.exactRef(cmd.getRefName()))) { if (!matchOld(cmd, refdb.exactRef(cmd.getRefName()))) {
cmd.setResult(LOCK_FAILURE); cmd.setResult(LOCK_FAILURE);
if (isAtomic()) { if (isAtomic()) {
ReceiveCommand.abort(pending); ReceiveCommand.abort(pending);

Loading…
Cancel
Save