Don't advertise refs/cache-automerge during push

The cache-automerge space is composed of tree objects that were
made on the fly by the server before presenting a merge commit in
the web UI. Clients are unlikely to have these objects locally,
and therefore cannot used them as a preferred base when creating a
pack for transmission to the server. Save a little bit of network
traffic by hiding them.

Change-Id: I806b5b3b91febbd5b63bc2faeef8df4bd6d101d4
This commit is contained in:
Shawn O. Pearce
2012-11-09 11:45:57 -08:00
parent d19be975e2
commit 3e49de3d1a

View File

@@ -38,10 +38,16 @@ public class ReceiveCommitsAdvertiseRefsHook implements AdvertiseRefsHook {
}
HashMap<String, Ref> r = new HashMap<String, Ref>();
for (Map.Entry<String, Ref> e : oldRefs.entrySet()) {
if (!e.getKey().startsWith("refs/changes/")) {
r.put(e.getKey(), e.getValue());
String name = e.getKey();
if (!skip(name)) {
r.put(name, e.getValue());
}
}
rp.setAdvertisedRefs(r, rp.getAdvertisedObjects());
}
private static boolean skip(String name) {
return name.startsWith("refs/changes/")
|| name.startsWith(GitRepositoryManager.REFS_CACHE_AUTOMERGE);
}
}