+ const gitSSHCommand = "GIT_SSH_COMMAND="
+ var sshCmd []string
+
+ // If we have an existing GIT_SSH_COMMAND, we need to append our options.
+ // We will also remove our old entry to make sure the behavior is the same
+ // with versions of Go < 1.9.
+ env := os.Environ()
+ for i, v := range env {
+ if strings.HasPrefix(v, gitSSHCommand) {
+ sshCmd = []string{v}
+
+ env[i], env[len(env)-1] = env[len(env)-1], env[i]
+ env = env[:len(env)-1]
+ break
+ }
+ }
+
+ if len(sshCmd) == 0 {
+ sshCmd = []string{gitSSHCommand + "ssh"}
+ }