Never replicate automerge-cache commits Whenever a change is diffed in the UI, the merge result is stored as a commit under the refs/automerge-cache namespace in the related git. These commits are then replicated, which is not necessary. Add checks to prevent these commits from being replicated. Change-Id: Ia1896a822a9901918d318d7641e2e8b63a0cf355
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 27a3901..afd7f91 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -426,7 +426,7 @@ boolean noPerms = !pool.isReplicatePermissions(); Map<String, Ref> remote = listRemote(tn); for (Ref src : local.values()) { - if (noPerms && GitRepositoryManager.REF_CONFIG.equals(src.getName())) { + if (!canPushRef(src.getName(), noPerms)) { continue; } @@ -463,8 +463,7 @@ if (spec != null) { // If the ref still exists locally, send it, otherwise delete it. Ref srcRef = local.get(src); - if (srcRef != null && - !(noPerms && GitRepositoryManager.REF_CONFIG.equals(src))) { + if (srcRef != null && canPushRef(src, noPerms)) { push(cmds, spec, srcRef); } else if (config.isMirror()) { delete(cmds, spec); @@ -474,6 +473,11 @@ return cmds; } + private boolean canPushRef(String ref, boolean noPerms) { + return !(noPerms && GitRepositoryManager.REF_CONFIG.equals(ref)) && + !ref.startsWith(GitRepositoryManager.REFS_CACHE_AUTOMERGE); + } + private Map<String, Ref> listRemote(Transport tn) throws NotSupportedException, TransportException { FetchConnection fc = tn.openFetch();