post-receive hook to enable hiding refs/changes during replication
post-receive hook to enable hiding refs/changes during replication

In the gerrit master configure the replication plugin to push changes
from  refs/changes/ to refs/tmp/changes/:

remote.NAME.push = +refs/changes/*:refs/tmp/changes/*

Install this hook script as post-receive hook in replicated repositories
hosted by a gerrit slave which are updated by push replication from
the corresponding gerrit master.

In the slave repository configure

receive.hideRefs = refs/changes/

in order to not advertise the big number of refs in this namespace
when replication is pushing another change.

Whenever a ref arrives under refs/tmp/changes/ this git post-receive
hook will move it to refs/changes/. This helps to avoid the large
overhead of receive-pack advertising all refs/changes/ refs when
the gerrit master pushes a pack.

We observed a speedup by a factor of 10 when using this replication
strategy for replication of a large repository with >400k refs across
a WAN link from Germany to Canada.

Change-Id: I6115c1ddbcb8e39cc0bdea999262287a9dc36743

GerritCodeReview/gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit,GerritCodeReview/gerrit