Merge branch 'fl/askpass'
* fl/askpass: git-core: Support retrieving passwords with GIT_ASKPASS git-svn: Support retrieving passwords with GIT_ASKPASS
This commit is contained in:
27
git-svn.perl
27
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user