diff options
-rw-r--r-- | Documentation/config.txt | 13 | ||||
-rw-r--r-- | connect.c | 26 |
2 files changed, 39 insertions, 0 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt index af2ae4cc02..8ea1db49c6 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -455,6 +455,19 @@ core.sshCommand:: the `GIT_SSH_COMMAND` environment variable and is overridden when the environment variable is set. +core.sshVariant:: + SSH implementations used by Git when running `git fetch`, + `git clone`, and `git push` use slightly different command + line options (e.g. PuTTY and TortoisePlink use `-P <port>` + while OpenSSH uses `-p <port>` to specify the port number. + TortoisePlink in addition requires `-batch` option to be + passed). Git guesses which variant is in use correctly from + the name of the ssh command used (see `core.sshCommand` + configuration variable and also `GIT_SSH_COMMAND` + environment variable) most of the time. You can set this + variable to 'putty', 'tortoiseplink', or 'ssh' to correct it + when Git makes an incorrect guess. + core.ignoreStat:: If true, Git will avoid using lstat() calls to detect if files have changed by setting the "assume-unchanged" bit for those tracked files @@ -691,6 +691,29 @@ static const char *get_ssh_command(void) return NULL; } +static void override_ssh_variant(int *port_option, int *needs_batch) +{ + const char *variant; + + if (git_config_get_string_const("core.sshvariant", &variant)) + return; + if (!strcmp(variant, "tortoiseplink")) { + *port_option = 'P'; + *needs_batch = 1; + } else if (!strcmp(variant, "putty")) { + *port_option = 'P'; + *needs_batch = 0; + } else { + /* default */ + if (strcmp(variant, "ssh")) { + warning(_("core.sshvariant: unknown value '%s'"), variant); + warning(_("using OpenSSH compatible behaviour")); + } + *port_option = 'p'; + *needs_batch = 0; + } +} + /* * This returns a dummy child_process if the transport protocol does not * need fork(2), or a struct child_process object if it does. Once done, @@ -836,6 +859,9 @@ struct child_process *git_connect(int fd[2], const char *url, argv_array_push(&conn->args, "-4"); else if (flags & CONNECT_IPV6) argv_array_push(&conn->args, "-6"); + + override_ssh_variant(&port_option, &needs_batch); + if (needs_batch) argv_array_push(&conn->args, "-batch"); if (port) { |