git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password
@ 2010-02-23 11:11 Frank Li
  2010-02-23 23:31 ` Laszlo Papp
  2010-02-24  5:13 ` David Aguilar
  0 siblings, 2 replies; 8+ messages in thread
From: Frank Li @ 2010-02-23 11:11 UTC (permalink / raw)
  To: git; +Cc: Frank Li

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-02-26  0:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23 11:11 [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password Frank Li
2010-02-23 23:31 ` Laszlo Papp
2010-02-24  5:13 ` David Aguilar
2010-02-24  5:31   ` Junio C Hamano
2010-02-24  8:13   ` Frank Li
2010-02-25  9:15     ` David Aguilar
2010-02-25 17:15       ` Laszlo Papp
2010-02-26  0:15       ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).