mirror of
https://github.com/git/git.git
synced 2026-03-13 10:23:30 +01:00
connect.c: Fix custom port SSH with PuTTY plink on Windows
OpenSSH uses -p to specify custom ports, while PuTTY uses -P. Git should detect if plink is in GIT_SSH and modify its flags as necessary. Also fixed is a possible hang due to faulty stdin forwarding to plink when plink attempts to be interactive. Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com> Signed-off-by: Steffen Prohaska <prohaska@zib.de>
This commit is contained in:
committed by
Steffen Prohaska
parent
f01c16a4bb
commit
54b9e8917c
14
connect.c
14
connect.c
@@ -596,14 +596,24 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
|
||||
die("command line too long");
|
||||
|
||||
conn->in = conn->out = -1;
|
||||
conn->argv = arg = xcalloc(6, sizeof(*arg));
|
||||
/* be sure to increase this size if you add more args */
|
||||
conn->argv = arg = xcalloc(8, sizeof(*arg));
|
||||
if (protocol == PROTO_SSH) {
|
||||
const char *ssh = getenv("GIT_SSH");
|
||||
int putty = ssh && strstr(ssh, "plink");
|
||||
if (!ssh) ssh = "ssh";
|
||||
|
||||
*arg++ = ssh;
|
||||
if (putty) {
|
||||
/* stdin forwarding doesn't work, so give informative error messages
|
||||
* (-v) and don't hang (-batch).
|
||||
*/
|
||||
*arg++ = "-batch";
|
||||
*arg++ = "-v";
|
||||
}
|
||||
if (port) {
|
||||
*arg++ = "-p";
|
||||
/* P is for PuTTY, p is for OpenSSH */
|
||||
*arg++ = putty ? "-P" : "-p";
|
||||
*arg++ = port;
|
||||
}
|
||||
*arg++ = host;
|
||||
|
||||
Reference in New Issue
Block a user