From: Junio C Hamano Date: Wed, 04 Jan 2012 19:08:01 GMT Subject: Re: [PATCH 1/2] git-svn, perl/Git.pm: add central method for prompting passwords honoring GIT_ASKPASS and SSH_ASKPASS Message-ID: <7vipkrp9pq.fsf@alter.siamese.dyndns.org> In-Reply-To: <4F040E46.5030001@tu-clausthal.de> Sven Strickroth writes: > Am 04.01.2012 08:55 schrieb Sven Strickroth: >> The Git.pm part is easy, but I also tried to update prompt.c (untested). > > I said "easy" and then I mailed the wrong/outdated patch :( > I'm sorry for the noise. > > From: Sven Strickroth > Date: Wed, 4 Jan 2012 08:44:48 +0100 > Subject: [PATCH] Git.pm, prompt: try reading from interactive terminal > before using SSH_ASKPASS > > SVN tries to read reading from interactive terminal before using > SSH_ASKPASS helper. This change adjust git to behave the same way. It might be an accurate description of what Subversion does ("tries to" is the key phrase). I however do not know if it is equivalent to what your patch does. When GIT_ASKPASS is not set, the $prompt is given to the standard error stream unconditionally and then the "require Term::ReadKey" codepath is used. When the terminal is unavailable, you might get undef in $ret and be able to fall back on SSH_ASKPASS part, but you cannot take back the noise you have given to the standard error stream. Is there a way to ask Term::ReadKey (or possibly some other module) if we will be able to interact with the terminal _before_ we give that prompt? The simplest would be to do this, I would think, but I didn't test it. if (!defined $ret && -t) { print STDERR $prompt; if ($isPassword) { ... } if (!defined $ret) { $ret = _prompt($ENV{'SSH_ASKPASS'}, $prompt); }