git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-02  8:32         ` [PATCH 05/12] Windows(msysgit): Per default, display help as HTML in default browser Steffen Prohaska
@ 2008-07-02  8:32           ` Steffen Prohaska
  2008-07-02 19:04             ` Johannes Sixt
  0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2008-07-02  8:32 UTC (permalink / raw)
  To: Johannes Sixt
  Cc: git, msysgit, Junio C Hamano, Edward Z. Yang, Steffen Prohaska


From: Edward Z. Yang <edwardzyang@thewritingpot.com>

PuTTY requires -P while OpenSSH requires -p; if plink is detected
as GIT_SSH, use the alternate flag.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 connect.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/connect.c b/connect.c
index 574f42f..0d007f3 100644
--- a/connect.c
+++ b/connect.c
@@ -599,11 +599,13 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 	conn->argv = arg = xcalloc(6, 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 (port) {
-			*arg++ = "-p";
+			/* P is for PuTTY, p is for OpenSSH */
+			*arg++ = putty ? "-P" : "-p";
 			*arg++ = port;
 		}
 		*arg++ = host;
-- 
1.5.6.1.255.g32571

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-02  8:32           ` [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh) Steffen Prohaska
@ 2008-07-02 19:04             ` Johannes Sixt
  2008-07-03 11:10               ` Johannes Schindelin
  2008-07-04  9:18               ` Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Johannes Sixt @ 2008-07-02 19:04 UTC (permalink / raw)
  To: prohaska; +Cc: msysGit, git, Junio C Hamano, Edward Z. Yang


On Mittwoch, 2. Juli 2008, Steffen Prohaska wrote:
> From: Edward Z. Yang <edwardzyang@thewritingpot.com>
>
> PuTTY requires -P while OpenSSH requires -p; if plink is detected
> as GIT_SSH, use the alternate flag.
>
> Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
> Signed-off-by: Steffen Prohaska <prohaska@zib.de>
> ---
>  connect.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/connect.c b/connect.c
> index 574f42f..0d007f3 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -599,11 +599,13 @@ struct child_process *git_connect(int fd[2], const
> char *url_orig, conn->argv = arg = xcalloc(6, 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 (port) {
> -			*arg++ = "-p";
> +			/* P is for PuTTY, p is for OpenSSH */
> +			*arg++ = putty ? "-P" : "-p";
>  			*arg++ = port;
>  		}
>  		*arg++ = host;

What about installing a wrapper script, plinkssh, that does this:

#!/bin/bash

if test "$1" = -p; then
	port="-P $2"
	shift; shift
fi

exec plink $port "$@"

and require plink users to set GIT_SSH=plinkssh?

-- Hannes

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
@ 2008-07-03  3:07 Edward Z. Yang
  2008-07-03 12:29 ` Johannes Schindelin
  0 siblings, 1 reply; 10+ messages in thread
From: Edward Z. Yang @ 2008-07-03  3:07 UTC (permalink / raw)
  To: git; +Cc: gitster, msysGit, junio


Johannes Sixt wrote:
 > What about installing a wrapper script, plinkssh, that does this:
 > [snip]

Well, the patch is shorter :-)

Joking aside, it's a good question. I guess I prefer the patch because:

1. It's been tested, it works. I haven't tried the script yet, so I 
don't know if it works.

2. Git historically doesn't use bash, so the script would have to be 
rewritten in Perl or plain sh or tcl or something.

3. It's less brittle than the wrapper script if we decide to have Git 
pass more params to OpenSSH.

4. It's "more native".

I don't know if these are compelling enough reasons, though.

(cc'ed everyone else, whoops)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-02 19:04             ` Johannes Sixt
@ 2008-07-03 11:10               ` Johannes Schindelin
  2008-07-04  8:50                 ` Steffen Prohaska
  2008-07-04  9:18               ` Junio C Hamano
  1 sibling, 1 reply; 10+ messages in thread
From: Johannes Schindelin @ 2008-07-03 11:10 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: prohaska, msysGit, git, Junio C Hamano, Edward Z. Yang


Hi,

On Wed, 2 Jul 2008, Johannes Sixt wrote:

> On Mittwoch, 2. Juli 2008, Steffen Prohaska wrote:
> > From: Edward Z. Yang <edwardzyang@thewritingpot.com>
> >
> > PuTTY requires -P while OpenSSH requires -p; if plink is detected
> > as GIT_SSH, use the alternate flag.
> >
> > Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
> > Signed-off-by: Steffen Prohaska <prohaska@zib.de>
> > ---
> >  connect.c |    4 +++-
> >  1 files changed, 3 insertions(+), 1 deletions(-)
> >
> > diff --git a/connect.c b/connect.c
> > index 574f42f..0d007f3 100644
> > --- a/connect.c
> > +++ b/connect.c
> > @@ -599,11 +599,13 @@ struct child_process *git_connect(int fd[2], const
> > char *url_orig, conn->argv = arg = xcalloc(6, 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 (port) {
> > -			*arg++ = "-p";
> > +			/* P is for PuTTY, p is for OpenSSH */
> > +			*arg++ = putty ? "-P" : "-p";
> >  			*arg++ = port;
> >  		}
> >  		*arg++ = host;
> 
> What about installing a wrapper script, plinkssh, that does this:
> 
> #!/bin/bash
> 
> if test "$1" = -p; then
> 	port="-P $2"
> 	shift; shift
> fi
> 
> exec plink $port "$@"
> 
> and require plink users to set GIT_SSH=plinkssh?

I like that better than this special-casing of plink.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-03  3:07 [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh) Edward Z. Yang
@ 2008-07-03 12:29 ` Johannes Schindelin
  2008-07-04 20:05   ` Edward Z. Yang
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Schindelin @ 2008-07-03 12:29 UTC (permalink / raw)
  To: Edward Z. Yang; +Cc: git, gitster, msysGit, junio


Hi,

On Wed, 2 Jul 2008, Edward Z. Yang wrote:

> Johannes Sixt wrote:
> > What about installing a wrapper script, plinkssh, that does this:
> > [snip]
> 
> Well, the patch is shorter :-)

But you have to do it for every SSH backend that you might want to 
support.

And you have to recompile.

> 1. It's been tested, it works. I haven't tried the script yet, so I 
>    don't know if it works.

Sorry, that argument does not fly.  "My patch is better, because I did not 
test your patch."

> 2. Git historically doesn't use bash, so the script would have to be 
>    rewritten in Perl or plain sh or tcl or something.

That is so totally untrue.  We have Perl scripts and Shell scripts (for 
which we need the bash), and then we have the two GUIs which use Tcl/Tk.

Actually, we only have so few Perl scripts left that it might be possible 
to ship a version of Git on Windows without Perl.  The only script that 
needs to be converted to a builtin is add -i.

The rest of the scripts are shell.

So this argument is totally bogus.

> 3. It's less brittle than the wrapper script if we decide to have Git 
>    pass more params to OpenSSH.

Granted, should we decide one day to use more elaborate features of 
OpenSSH, then we would have to change the script, too.

But most likely, Plink support would be broken by that update _anyway_, 
since it does not grok the OpenSSH options directly.

And guess what is easier to fix, a script that rewrites the arguments from 
OpenSSH syntax to Plink syntax, or a C program with over 78,000 code 
lines that has to be recompiled?

> 4. It's "more native".

Would it not be even more native if we just linked in libssl?  Would you 
write the patch?

Further, would you like to convert and maintain all people's wrapper 
scripts to C code inside Git?

BTW what is the reason why Hannes' mail does not appear to be the mail 
you replied to in GMane, but the patch Steffen sent?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-03 11:10               ` Johannes Schindelin
@ 2008-07-04  8:50                 ` Steffen Prohaska
  0 siblings, 0 replies; 10+ messages in thread
From: Steffen Prohaska @ 2008-07-04  8:50 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Johannes Sixt, msysGit, git, Junio C Hamano, Edward Z. Yang



On Jul 3, 2008, at 1:10 PM, Johannes Schindelin wrote:

> On Wed, 2 Jul 2008, Johannes Sixt wrote:
>
>> On Mittwoch, 2. Juli 2008, Steffen Prohaska wrote:
>>> From: Edward Z. Yang <edwardzyang@thewritingpot.com>
>>>
>>> PuTTY requires -P while OpenSSH requires -p; if plink is detected
>>> as GIT_SSH, use the alternate flag.
>>>
>>> Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
>>> Signed-off-by: Steffen Prohaska <prohaska@zib.de>
>>> ---
>>> connect.c |    4 +++-
>>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/connect.c b/connect.c
>>> index 574f42f..0d007f3 100644
>>> --- a/connect.c
>>> +++ b/connect.c
>>> @@ -599,11 +599,13 @@ struct child_process *git_connect(int fd[2],  
>>> const
>>> char *url_orig, conn->argv = arg = xcalloc(6, 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 (port) {
>>> -			*arg++ = "-p";
>>> +			/* P is for PuTTY, p is for OpenSSH */
>>> +			*arg++ = putty ? "-P" : "-p";
>>> 			*arg++ = port;
>>> 		}
>>> 		*arg++ = host;
>>
>> What about installing a wrapper script, plinkssh, that does this:
>>
>> #!/bin/bash
>>
>> if test "$1" = -p; then
>> 	port="-P $2"
>> 	shift; shift
>> fi
>>
>> exec plink $port "$@"
>>
>> and require plink users to set GIT_SSH=plinkssh?
>
> I like that better than this special-casing of plink.


I'd prefer to change connect.c.  plinkssh would introduce another
dependency on the shell, while our overall goal is to avoid shell as
much as possible on Windows, no?  Edward's solution also looks more
obvious to me than the plinkssh wrapper script.

	Steffen

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-02 19:04             ` Johannes Sixt
  2008-07-03 11:10               ` Johannes Schindelin
@ 2008-07-04  9:18               ` Junio C Hamano
  2008-07-04  9:29                 ` Steffen Prohaska
  1 sibling, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2008-07-04  9:18 UTC (permalink / raw)
  To: johannes.sixt; +Cc: prohaska, msysGit, git, Edward Z. Yang

Johannes Sixt <johannes.sixt@telecom.at> writes:

> What about installing a wrapper script, plinkssh, that does this:
>
> #!/bin/bash
>
> if test "$1" = -p; then
> 	port="-P $2"
> 	shift; shift
> fi
>
> exec plink $port "$@"
>
> and require plink users to set GIT_SSH=plinkssh?

That's quite a nice solution with absolute minimum impact.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-04  9:18               ` Junio C Hamano
@ 2008-07-04  9:29                 ` Steffen Prohaska
  2008-07-04 16:09                   ` Clifford Caoile
  0 siblings, 1 reply; 10+ messages in thread
From: Steffen Prohaska @ 2008-07-04  9:29 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: johannes.sixt, msysGit, git, Edward Z. Yang



On Jul 4, 2008, at 11:18 AM, Junio C Hamano wrote:

> Johannes Sixt <johannes.sixt@telecom.at> writes:
>
>> What about installing a wrapper script, plinkssh, that does this:
>>
>> #!/bin/bash
>>
>> if test "$1" = -p; then
>> 	port="-P $2"
>> 	shift; shift
>> fi
>>
>> exec plink $port "$@"
>>
>> and require plink users to set GIT_SSH=plinkssh?
>
> That's quite a nice solution with absolute minimum impact.

It has minimum impact on the source code of git.  The same is not
true, however, for the git user and the installer on Windows:

  - The proposed plinkssh requires that plink is in the PATH.  This is
    not necessarily the case on Windows.  If plink is not in the PATH,
    then the user needs to modify plinkssh.

  - The msysgit installer supports setting GIT_SSH to the full path
    of plink.  It automatically detects this path based on Putty's
    entries in the Windows registry.  If we choose the plinkssh
    solution the installer has to be modified.

Setting '-P' in connect.c would have some impact on the git source,
but would avoid changes elsewhere.

	Steffen

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-04  9:29                 ` Steffen Prohaska
@ 2008-07-04 16:09                   ` Clifford Caoile
  0 siblings, 0 replies; 10+ messages in thread
From: Clifford Caoile @ 2008-07-04 16:09 UTC (permalink / raw)
  To: prohaska; +Cc: Junio C Hamano, johannes.sixt, msysGit, git, Edward Z. Yang


Hi:

On Fri, Jul 4, 2008 at 6:29 PM, Steffen Prohaska <prohaska@zib.de> wrote:
>
> On Jul 4, 2008, at 11:18 AM, Junio C Hamano wrote:
>
>> Johannes Sixt <johannes.sixt@telecom.at> writes:
>>
>>> What about installing a wrapper script, plinkssh, that does this:
>>
>> That's quite a nice solution with absolute minimum impact.
>
> It has minimum impact on the source code of git.  The same is not
> true, however, for the git user and the installer on Windows:
>
>  - The proposed plinkssh requires that plink is in the PATH.  This is
>   not necessarily the case on Windows.  If plink is not in the PATH,
>   then the user needs to modify plinkssh.
>
>  - The msysgit installer supports setting GIT_SSH to the full path
>   of plink.  It automatically detects this path based on Putty's
>   entries in the Windows registry.  If we choose the plinkssh
>   solution the installer has to be modified.

How about we create one more global environment variable
MSYSGIT_REAL_PLINK which points to the Windows plink during
installation? Then we set the GIT_SSH to the plinkssh, and the
proposed plinkssh can point to MSYSGIT_REAL_PLINK?

+ # fall back to plink if MSYSGIT_REAL_PLINK is not defined
+ # and hope plink is in the path
+ plink=${MSYSGIT_REAL_PLINK:-plink}

- exec plink $port "$@"
+ exec ${plink} $port "$@"

Perhaps I have traded one problem for another, because the msysgit
user still has to be aware of MSYSGIT_REAL_PLINK (at least she doesn't
have to set it up). And of course, the installer has to be modified to
accommodate plinkssh and my proposal.

Best regards,
Clifford Caoile

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh)
  2008-07-03 12:29 ` Johannes Schindelin
@ 2008-07-04 20:05   ` Edward Z. Yang
  0 siblings, 0 replies; 10+ messages in thread
From: Edward Z. Yang @ 2008-07-04 20:05 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: msysGit, git, gitster, junio


> Sorry, that argument does not fly.  "My patch is better, because I did not 
> test your patch."

Just tested, the patch works.

> That is so totally untrue.  We have Perl scripts and Shell scripts (for 
> which we need the bash), and then we have the two GUIs which use Tcl/Tk.

I came up with that conclusion by grepping the Git source code for the 
word bash; no results. Granted, it's still a null point because the 
proposed script doesn't use any bash-specific features.

> Further, would you like to convert and maintain all people's wrapper 
> scripts to C code inside Git?

I was under the impression that wrapper scripts were for fleshing out 
new APIs and implementing non-performance critical functionality, 
without all the overhead of writing in C. There is little to no overhead 
from this patch.

Anyway, Johannes still makes some pretty compelling points for the 
wrapper script, so you can count me +1 for the wrapper.

> BTW what is the reason why Hannes' mail does not appear to be the mail 
> you replied to in GMane, but the patch Steffen sent?

I actually did a "Reply" and so he was the only one who got the email at 
first. Then I resent it to the list, as well as the other CC'ed people.

(Thus my comment at the bottom)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-07-04 20:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03  3:07 [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh) Edward Z. Yang
2008-07-03 12:29 ` Johannes Schindelin
2008-07-04 20:05   ` Edward Z. Yang
  -- strict thread matches above, loose matches on Subject: below --
2008-07-02  8:31 How to reduce remaining differences to 4msysgit? (was What's cooking in git.git (topics)) Steffen Prohaska
2008-07-02  8:32 ` [PATCH 01/12] Fake reencoding success under NO_ICONV instead of returning NULL Steffen Prohaska
2008-07-02  8:32   ` [PATCH 02/12] Do not complain about "no common commits" in an empty repo Steffen Prohaska
2008-07-02  8:32     ` [PATCH 03/12] MinGW: Convert CR/LF to LF in tag signatures Steffen Prohaska
2008-07-02  8:32       ` [PATCH 04/12] Avoid calling signal(SIGPIPE, ..) for MinGW builds Steffen Prohaska
2008-07-02  8:32         ` [PATCH 05/12] Windows(msysgit): Per default, display help as HTML in default browser Steffen Prohaska
2008-07-02  8:32           ` [PATCH 06/12] connect: Fix custom ports with plink (Putty's ssh) Steffen Prohaska
2008-07-02 19:04             ` Johannes Sixt
2008-07-03 11:10               ` Johannes Schindelin
2008-07-04  8:50                 ` Steffen Prohaska
2008-07-04  9:18               ` Junio C Hamano
2008-07-04  9:29                 ` Steffen Prohaska
2008-07-04 16:09                   ` Clifford Caoile

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).