git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password

From
LPLaszlo Papp <djszapi@archlinux.us>
Date
Feb 23, 2010, 23:31 UTC
Message-ID
<a362e8011002231531k17725788sb45e70428c33848b@mail.gmail.com>
In-Reply-To
<1266923463-2828-1-git-send-email-lznuaa@gmail.com>
Nice to see someone who are interested in the solution to hack it :-)
On 2/23/10, Frank Li <lznuaa@gmail.com> wrote:
Show 56 quoted lines
> Default git-svn read charactor from terminal to get password. GUI will
> wait forever because don't know password need input.
>
> Signed-off-by: Frank Li <lznuaa@gmail.com>
> ---
>  git-svn.perl |   27 +++++++++++++++++----------
>  1 files changed, 17 insertions(+), 10 deletions(-)
>
> 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);
> +	} else {
> +		print STDERR $prompt;
> +		STDERR->flush;
> +		require Term::ReadKey;
> +		Term::ReadKey::ReadMode('noecho');
> +		while (defined(my $key = Term::ReadKey::ReadKey(0))) {
> +			last if $key =~ /[\012\015]/; # \n\r
> +			$password .= $key;
> +		}
> +		Term::ReadKey::ReadMode('restore');
> +		print STDERR "\n";
> +		STDERR->flush;
>  	}
> -	Term::ReadKey::ReadMode('restore');
> -	print STDERR "\n";
> -	STDERR->flush;
>  	$password;
>  }
>
> --
> 1.7.0.83.g241b9.dirty
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Previous: Frank LiNext: David Aguilar
Message 2 of 8 in “Use GIT_ASKPASS environment to launch thirdpart UI app to get password”
  1. 1/1 Use GIT_ASKPASS environment to launch thirdpart UI app to get passwordFrank Li, Feb 23, 2010
  2. Laszlo PappFeb 23, 2010
  3. David AguilarFeb 24, 2010
  4. Junio C HamanoFeb 24, 2010
  5. Frank LiFeb 24, 2010
  6. David AguilarFeb 25, 2010
  7. Laszlo PappFeb 25, 2010
  8. Frank LiFeb 26, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.