Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password
- From
David Aguilar <davvid@gmail.com>
- Date
- Feb 24, 2010, 05:13 UTC
- Message-ID
- <20100224051307.GA3232@gmail.com>
- In-Reply-To
- <1266923463-2828-1-git-send-email-lznuaa@gmail.com>
On Tue, Feb 23, 2010 at 07:11:03PM +0800, Frank Li wrote:
> Default git-svn read charactor from terminal to get password. GUI will > wait forever because don't know password need input.
What do you think about this message instead?
-- >8 -- Subject: [PATCH] git-svn: Support retrieving passwords with GIT_ASKPASS
git-svn reads passwords from an interactive terminal. This behavior causes GUIs to hang waiting for git-svn to complete.
Fix this problem by allowing a password-retrieving command to be specified in GIT_ASKPASS. SSH_ASKPASS is supported as a fallback when GIT_ASKPASS is not provided.
(see note below)
Show 21 quoted lines
> diff --git a/git-svn.perl b/git-svn.perl
> index 265852f..f9f104e 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -3966,18 +3966,25 @@ sub username {
>
> sub _read_password {
> my ($prompt, $realm) = @_;
> - print STDERR $prompt;
> - STDERR->flush;
> - require Term::ReadKey;
> - Term::ReadKey::ReadMode('noecho');
> my $password = '';
> - while (defined(my $key = Term::ReadKey::ReadKey(0))) {
> - last if $key =~ /[\012\015]/; # \n\r
> - $password .= $key;
> + if (exists $ENV{GIT_ASKPASS}) {
> + open(PH, "$ENV{GIT_ASKPASS} \"$prompt\" |");
> + $password = <PH>;
> + $password =~ s/[\012\015]//; # \n\r
> + close(PH);I think Junio mentioned this in passing but I'll repeat it.
Many users already have SSH_ASKPASS defined. It would be very nice if we supported SSH_ASKPASS as a fallback when GIT_ASKPASS is not provided.
-- David