Merge branch 'stable-2.15'

* stable-2.15:
  Support an extra command for ssh command

Change-Id: If2f68f9c83dae2faf038718d9ec94ba31587e330
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
index 8c394cc..5fcedf5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
@@ -30,6 +30,7 @@
   private static final String TARGET = " `git rev-parse --git-dir`/";
 
   private final String configCommand;
+  private final String extraCommand;
   private final SshScheme sshScheme;
   private final Provider<CurrentUser> userProvider;
 
@@ -37,6 +38,7 @@
   CloneWithCommitMsgHook(
       @GerritServerConfig Config config, SshScheme sshScheme, Provider<CurrentUser> userProvider) {
     this.configCommand = config.getString("gerrit", null, "installCommitMsgHookCommand");
+    this.extraCommand = config.getString("gerrit", null, "installCommitExtraCommand");
     this.sshScheme = sshScheme;
     this.userProvider = userProvider;
   }
@@ -78,6 +80,9 @@
           .append(projectName)
           .append("/.git/hooks/");
 
+      if (extraCommand != null) {
+        b.append(" && (cd ").append(projectName).append(" && ").append(extraCommand).append(")");
+      }
       return b.toString();
     }
 
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index bcd27a9..3781f9e 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -87,3 +87,25 @@
 		  allowTipSHA1InWant = true
 
 	By default `false`.
+
+
+### <a id="gerrit">Section gerrit</a>
+
+```
+[gerrit]
+  installCommitMsgHookCommand = command
+  installCommitExtraCommand = command
+```
+
+<a id="gerrit.installCommitMsgHookCommand">gerrit.installCommitMsgHookCommand</a>
+  Optional command to install the commit-msg hook. Typically of the form:
+  `fetch-cmd some://url/to/commit-msg .git/hooks/commit-msg ; chmod +x .git/hooks/commit-msg`
+  By default unset; falls back to using scp from the canonical SSH host,
+  or curl from the canonical HTTP URL for the server. Only necessary
+  if a proxy or other server/network configuration prevents clients
+  from fetching from the default location.
+
+<a id="gerrit.installCommitExtraCommand">gerrit.installCommitExtraCommand</a>
+  Optional command to complete the commit-msg hook. For example:
+  `git submodule update --init --recursive && git review -s`
+  would initialize the submodules and setup git review.
\ No newline at end of file