connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config
This environment variable and configuration value allow to override the autodetection of plink/tortoiseplink in case that Git gets it wrong. [jes: wrapped overly-long lines, factored out and changed get_ssh_variant() to handle_ssh_variant() to accomodate the change from the putty/tortoiseplink variables to port_option/needs_batch, adjusted the documentation, free()d value obtained from the config.] Signed-off-by: Segev Finer <segev208@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e2824e47e7
commit
dd33e07766
11
connect.c
11
connect.c
@ -694,10 +694,14 @@ static const char *get_ssh_command(void)
|
||||
static int handle_ssh_variant(const char *ssh_command, int is_cmdline,
|
||||
int *port_option, int *needs_batch)
|
||||
{
|
||||
const char *variant;
|
||||
const char *variant = getenv("GIT_SSH_VARIANT");
|
||||
char *p = NULL;
|
||||
|
||||
if (!is_cmdline) {
|
||||
if (variant)
|
||||
; /* okay, fall through */
|
||||
else if (!git_config_get_string("ssh.variant", &p))
|
||||
variant = p;
|
||||
else if (!is_cmdline) {
|
||||
p = xstrdup(ssh_command);
|
||||
variant = basename(p);
|
||||
} else {
|
||||
@ -717,7 +721,8 @@ static int handle_ssh_variant(const char *ssh_command, int is_cmdline,
|
||||
}
|
||||
|
||||
if (!strcasecmp(variant, "plink") ||
|
||||
!strcasecmp(variant, "plink.exe"))
|
||||
!strcasecmp(variant, "plink.exe") ||
|
||||
!strcasecmp(variant, "putty"))
|
||||
*port_option = 'P';
|
||||
else if (!strcasecmp(variant, "tortoiseplink") ||
|
||||
!strcasecmp(variant, "tortoiseplink.exe")) {
|
||||
|
Reference in New Issue
Block a user