summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-20 11:29:35 -0700
committerJunio C Hamano <gitster@pobox.com>2010-03-20 11:29:35 -0700
commit2e5b98d9064292881fb1fd7c327948c7057a490a (patch)
tree1186c102b8d47e45b0f6140af3d47ce43c1014aa /git-svn.perl
parent31fbae0f813b47801ee79a464a8257346a5f8f2c (diff)
parentf206063b4b201ff48c87b886cbe21a068fcf6d49 (diff)
downloadgit-2e5b98d9064292881fb1fd7c327948c7057a490a.tar.gz
Merge branch 'fl/askpass'
* fl/askpass: git-core: Support retrieving passwords with GIT_ASKPASS git-svn: Support retrieving passwords with GIT_ASKPASS
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl27
1 files changed, 17 insertions, 10 deletions
diff --git a/git-svn.perl b/git-svn.perl
index aceeca5a94..2c86ea2e38 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3971,18 +3971,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;
}