# Re: [PATCH] git_getpass: fix ssh-askpass behaviour

1 messages from 2010-12-13 to 2010-12-13. Participants: Xin Wang.
Thread: https://gitlist.dev/t/26034

## Xin Wang, 2010-12-13 04:09

Subject: Re: [PATCH] git_getpass: fix ssh-askpass behaviour
Message-ID: <AANLkTi=V-KrwU97-KFJHd2+i05e6qsZsyMHkwpRLhCHx@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DV-KrwU97-KFJHd2%2Bi05e6qsZsyMHkwpRLhCHx%40mail.gmail.com

```
Junio C Hamano <gitster <at> pobox.com> writes:

>
> Alexander Sulfrian <alexander <at> sulfrian.net> writes:
>
> > call ssh-askpass only if the display environment variable is also set
> > ---
>
> I do not use it at all so I don't know for sure, but doesn't this break
> OSX?
>
>   20f3490 (web--browse: fix Mac OS X GUI detection for 10.6, 2009-09-14)
>
> is an example that you can be fully graphical without having DISPLAY set
> in some environment.  MinGW folks may want to chime in as well.
>

How about test whether git is associated with a terminal or not?

> >  connect.c |    7 +++++--
> >  1 files changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/connect.c b/connect.c
> > index 57dc20c..2810e3b 100644
> > --- a/connect.c
> > +++ b/connect.c
> > @@ -621,7 +621,7 @@ int finish_connect(struct child_process *conn)
> >
> >  char *git_getpass(const char *prompt)
> >  {
> > -	const char *askpass;
> > +	const char *askpass, *display;
> >  	struct child_process pass;
> >  	const char *args[3];
> >  	static struct strbuf buffer = STRBUF_INIT;
> > @@ -631,7 +631,10 @@ char *git_getpass(const char *prompt)
> >  		askpass = askpass_program;
> >  	if (!askpass)
> >  		askpass = getenv("SSH_ASKPASS");
> > -	if (!askpass || !(*askpass)) {
> > +
> > +	/* only call askpass if display is set */
> > +	display = getenv("DISPLAY");
> > +	if (!display || !(*display) || !askpass || !(*askpass))
> >  		char *result = getpass(prompt);
> >  		if (!result)
> >  			die_errno("Could not read password");
>
>

Xin Wang

```
