summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorFrank Li <lznuaa@gmail.com>2010-03-02 19:47:52 +0800
committerJunio C Hamano <gitster@pobox.com>2010-03-02 12:52:51 -0800
commit56a853b62c0ae7ebaad0a7a0a704f5ef561eb795 (patch)
tree7b5ab48adb06fe80336b2ff84cd697a9c1d426a0 /git-svn.perl
parent82cd8358e8203fa02da18e8ee71449cb45c4157d (diff)
downloadgit-56a853b62c0ae7ebaad0a7a0a704f5ef561eb795.tar.gz
git-svn: Support retrieving passwords with GIT_ASKPASS
git-svn reads passwords from an interactive terminal. This behavior cause 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. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 49dd649bc5..07e95ad449 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3970,18 +3970,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;
}