Merge branch 'bc/connect-plink' into maint
The connection initiation code for "ssh" transport tried to absorb differences between the stock "ssh" and Putty-supplied "plink" and its derivatives, but the logic to tell that we are using "plink" variants were too loose and falsely triggered when "plink" appeared anywhere in the path (e.g. "/home/me/bin/uplink/ssh"). * bc/connect-plink: connect: improve check for plink to reduce false positives t5601: fix quotation error leading to skipped tests connect: simplify SSH connection code path
This commit is contained in:
56
connect.c
56
connect.c
@ -724,7 +724,7 @@ struct child_process *git_connect(int fd[2], const char *url,
|
||||
conn->in = conn->out = -1;
|
||||
if (protocol == PROTO_SSH) {
|
||||
const char *ssh;
|
||||
int putty;
|
||||
int putty, tortoiseplink = 0;
|
||||
char *ssh_host = hostandport;
|
||||
const char *port = NULL;
|
||||
get_host_and_port(&ssh_host, &port);
|
||||
@ -743,28 +743,40 @@ struct child_process *git_connect(int fd[2], const char *url,
|
||||
free(path);
|
||||
free(conn);
|
||||
return NULL;
|
||||
} else {
|
||||
ssh = getenv("GIT_SSH_COMMAND");
|
||||
if (ssh) {
|
||||
conn->use_shell = 1;
|
||||
putty = 0;
|
||||
} else {
|
||||
ssh = getenv("GIT_SSH");
|
||||
if (!ssh)
|
||||
ssh = "ssh";
|
||||
putty = !!strcasestr(ssh, "plink");
|
||||
}
|
||||
|
||||
argv_array_push(&conn->args, ssh);
|
||||
if (putty && !strcasestr(ssh, "tortoiseplink"))
|
||||
argv_array_push(&conn->args, "-batch");
|
||||
if (port) {
|
||||
/* P is for PuTTY, p is for OpenSSH */
|
||||
argv_array_push(&conn->args, putty ? "-P" : "-p");
|
||||
argv_array_push(&conn->args, port);
|
||||
}
|
||||
argv_array_push(&conn->args, ssh_host);
|
||||
}
|
||||
|
||||
ssh = getenv("GIT_SSH_COMMAND");
|
||||
if (ssh) {
|
||||
conn->use_shell = 1;
|
||||
putty = 0;
|
||||
} else {
|
||||
const char *base;
|
||||
char *ssh_dup;
|
||||
|
||||
ssh = getenv("GIT_SSH");
|
||||
if (!ssh)
|
||||
ssh = "ssh";
|
||||
|
||||
ssh_dup = xstrdup(ssh);
|
||||
base = basename(ssh_dup);
|
||||
|
||||
tortoiseplink = !strcasecmp(base, "tortoiseplink") ||
|
||||
!strcasecmp(base, "tortoiseplink.exe");
|
||||
putty = !strcasecmp(base, "plink") ||
|
||||
!strcasecmp(base, "plink.exe") || tortoiseplink;
|
||||
|
||||
free(ssh_dup);
|
||||
}
|
||||
|
||||
argv_array_push(&conn->args, ssh);
|
||||
if (tortoiseplink)
|
||||
argv_array_push(&conn->args, "-batch");
|
||||
if (port) {
|
||||
/* P is for PuTTY, p is for OpenSSH */
|
||||
argv_array_push(&conn->args, putty ? "-P" : "-p");
|
||||
argv_array_push(&conn->args, port);
|
||||
}
|
||||
argv_array_push(&conn->args, ssh_host);
|
||||
} else {
|
||||
/* remove repo-local variables from the environment */
|
||||
conn->env = local_repo_env;
|
||||
|
Reference in New Issue
Block a user