summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Philbert <alexandre.philbert@ericsson.com>2016-05-19 10:31:04 -0400
committerAlexandre Philbert <alexandre.philbert@ericsson.com>2016-05-19 15:07:19 -0400
commit7cbcfd2a3a507472eb244cf1a773b177d291d253 (patch)
tree8bb304384cbfb01d5cef725d0ab5a07e2118c976
parentb4584ad31125a13649de9a953bd931364fd5ae0b (diff)
Double check if a ref is missing locally before deleting from remotev2.12.3
Repository.getRefs sometimes does not return the correct list of refs in the local repository (missing some). For this reason, we double check using Repository.getRef. Without this check, the ref is deleted from the remote by mistake. The suspicion for the former function not returning the correct list is primarily heavy garbage collection. It isn't confirmed whether the latter function always returns the correct value. Possibly a second check isn't enough, but it still catches many occurences of the issue. The presumption is that getRef is more atomic than getRefs. Change-Id: I619c92c55e36a4b6719ef812bdddb2d3b2aab814
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
index 4a2d01b..66304bc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -483,6 +483,12 @@ class PushOne implements ProjectRunnable {
if (spec != null) {
// If the ref still exists locally, send it, otherwise delete it.
Ref srcRef = local.get(src);
+
+ // Second try to ensure that the ref is truly not found locally
+ if (srcRef == null) {
+ srcRef = git.getRef(src);
+ }
+
if (srcRef != null && canPushRef(src, noPerms)) {
push(cmds, spec, srcRef);
} else if (config.isMirror()) {