Change default push refSpec to 'refs/*:refs/*' (non-forced push) Using forced push as implicit default for replication to slaves could lead to unintended disruption on remote repositories. Default git push refSpec is non-forced so the user would expect Gerrit replication to apply the same default behaviour. See: http://bit.ly/1jEU2vp for disruption caused by default forced push Change-Id: I4509d3500c730b8b5921dc155ea0476a70b3de9e
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationFileBasedConfig.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationFileBasedConfig.java index 60a3918..0e3894b 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationFileBasedConfig.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationFileBasedConfig.java
@@ -118,8 +118,7 @@ } if (c.getPushRefSpecs().isEmpty()) { - c.addPushRefSpec(new RefSpec().setSourceDestination("refs/*", "refs/*") - .setForceUpdate(true)); + c.addPushRefSpec(new RefSpec().setSourceDestination("refs/*", "refs/*")); } Destination destination =
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md index 04f907c..9521375 100644 --- a/src/main/resources/Documentation/config.md +++ b/src/main/resources/Documentation/config.md
@@ -128,13 +128,20 @@ the active branches, but not the change refs under `refs/changes/`, or the tags under `refs/tags/`. + Note that prefixing a source refspec with `+` causes the replication + to be done with a `git push --force` command. + Be aware that when you are pushing to remote repositories that may + have read/write access (e.g. GitHub) you may want to omit the `+` + to prevent the risk of overwriting branches that have been modified + on the remote. + Multiple push keys can be supplied, to specify multiple patterns to match against. In the [example above][2], remote "pubmirror" uses two push keys to match both `refs/heads/*` and `refs/tags/*`, but excludes all others, including `refs/changes/*`. - Defaults to `+refs/*:refs/*` (all refs) if not specified. + Defaults to `refs/*:refs/*` (push all refs) if not specified. [2]: #example_file