diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-01-25 14:35:36 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-25 15:05:08 -0800 |
commit | aabadcf65291d16ecf7897ed2a26269ddb3f83d2 (patch) | |
tree | 868be7c9c840c5a50649986ca4ff0bbdaaf47329 /connect.c | |
parent | 1b1720a1399a7ab78aeb135922e90d086adf9f13 (diff) | |
download | git-sf/putty-plink-in-ssh-command.tar.gz |
connect: core.sshvariant to correct misidentificationsf/putty-plink-in-ssh-command
While the logic we have been using to guess which variant of SSH
implementation is in use by looking at the name of the program has
been robust enough for GIT_SSH (which does not go through the shell,
hence it can only spell the name the SSH program and nothing else),
extending it to GIT_SSH_COMMAND and core.sshcommand opens it for
larger chance of misidentification, because these can specify
arbitrary shell command, and a simple "the first word on the line
must be the command name" heuristic may not even look at the command
name at all.
As any effort to improve the heuristic will give us only diminishing
returns, and especially given that most of the users are expected to
have a command line for which the heuristic would work correctly,
give an explicit escape hatch to override a misidentification, just
in case one happens.
It is arguably bad to add this new variable to the core.* set, in
the sense that you'll never see this variable if you do not interact
with other repositories over ssh, but core.sshcommand is already
there for some reason, so let's match it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'connect.c')
-rw-r--r-- | connect.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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) { |