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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nice to see someone who are interested in the solution to hack it :-)

On 2/23/10, Frank Li <lznuaa@xxxxxxxxx> wrote:
> 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@xxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]