Here's an updated patch, and inline. Hopefully it isn't slaughtered by my 
mail-client (I followed the instructions but am not sure they worked). If I've 
missed any procedural things, please say so. (There's no tests, although I'm 
not sure how to test something like that.) Other issues addressed.

>From 833490faef92b85ab7076bd62b4782e0085451bd Mon Sep 17 00:00:00 2001
From: Edward Z. Yang <[EMAIL PROTECTED]>
Date: Thu, 5 Jun 2008 01:45:42 -0400
Subject: [PATCH] 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 <[EMAIL PROTECTED]>
---
 connect.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/connect.c b/connect.c
index 8d600c9..c6e6d60 100644
--- a/connect.c
+++ b/connect.c
@@ -595,14 +595,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;
-- 
1.5.5.1016.gde48.dirty


-- 
 Edward Z. Yang                        GnuPG: 0x869C48DA
 HTML Purifier <http://htmlpurifier.org> Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]

Reply via email to