Use GIT_ASKPASS environment to launch thirdpart UI app to get password
PATCH 1/1 Use GIT_ASKPASS environment to launch thirdpart UI app to get password
Default git-svn read charactor from terminal to get password. GUI will wait forever because don't know password need input.
--- git-svn.perl | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-)
git-svn.perl +17 -10
@@ -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; }
Signature · 1 line
1.7.0.83.g241b9.dirty
Quoted 2 lines · Frank Li
Default git-svn read charactor from terminal to get password. GUI will wait forever because don't know password need input.
What do you think about this message instead?
-- >8 --
Subject: [PATCH] git-svn: Support retrieving passwords with GIT_ASKPASS
git-svn reads passwords from an interactive terminal. This behavior causes 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.
(see note below)
Quoted 11 lines
git-svn.perl +0
-3@@ -3966,18 +3966,25 @@ sub username { sub _read_password { my ($prompt, $realm) = @_; - print STDERR $prompt; - STDERR->flush; - require Term::ReadKey;
git-svn.perl sub username { · line 3974
Quoted 10 lines
git-svn.perl +5
-4- 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);
I think Junio mentioned this in passing but I'll repeat it.
Many users already have SSH_ASKPASS defined. It would be very nice if we supported SSH_ASKPASS as a fallback when GIT_ASKPASS is not provided.
Signature · 1 line
David
Quoted 11 lines
-- >8 --
Subject: [PATCH] git-svn: Support retrieving passwords withGIT_ASKPASSgit-svn reads passwords from an interactive terminal. This behavior causes 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 whenGIT_ASKPASSis not provided.
Okay, I will change it.
Quoted 7 lines
I think Junio mentioned this in passing but I'll repeat it.
Many users already have
SSH_ASKPASSdefined. It would be very nice if we supportedSSH_ASKPASSas a fallback whenGIT_ASKPASSis not provided.
I consider add such fallback at git.c. when user use git svn, git main program will be called firstly.
git main entry will check if GIT_ASKPASS and SSH_ASKPASS, if SSH_ASKPASS set but GIT_ASKPASS not set,GIT_ASKPASS will be set as SSH_ASKPASS.
Do you think we needs add such check at git-svn.perl ?
best regards
Frank Li
Quoted 5 lines · David Aguilar
I think Junio mentioned this in passing but I'll repeat it.
Many users already have
SSH_ASKPASSdefined. It would be very nice if we supportedSSH_ASKPASSas a fallback whenGIT_ASKPASSis not provided.
Thanks; I think git-gui does something similar.
Nice to see someone who are interested in the solution to hack it :-)
Quoted 56 lines · 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 <[email protected]>--- git-svn.perl | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-)git-svn.perl +17
-11@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 12 lines · Frank Li
Quoted 5 lines
Many users already have
SSH_ASKPASSdefined. It would be very nice if we supportedSSH_ASKPASSas a fallback whenGIT_ASKPASSis not provided.I consider add such fallback at
git.c. when user use git svn, git main program will be called firstly.
git main entry will check ifGIT_ASKPASSandSSH_ASKPASS, ifSSH_ASKPASSset butGIT_ASKPASSnot set,GIT_ASKPASSwill be set asSSH_ASKPASS.
Quoted 4 lines
Do you think we needs add such check at git-svn.perl ?
best regards
Frank Li
Interesting question. I had never thought of moving the fallback to git.
I would have done it in the script as a localized fix but I definately see the value in aiding scripts from all having to implement this same fallback, though:
$ENV{GIT_ASKPASS} ||= $ENV{SSH_ASKPASS};If Junio, Eric, and the git list think that this should live in git instead then by all means.
Signature · 1 line
David
Quoted 7 lines
I would have done it in the script as a localized fix but I definately see the value in aiding scripts from all having to implement this same fallback, though:
$ENV{GIT_ASKPASS} ||= $ENV{SSH_ASKPASS};
Add it at [PATCH v2 1/3] git-svn: Support retrieving passwords with GIT_ASKPASS
Quoted 30 lines · David Aguilar
Quoted 12 lines · Frank Li
Quoted 5 lines
Many users already have
SSH_ASKPASSdefined. It would be very nice if we supportedSSH_ASKPASSas a fallback whenGIT_ASKPASSis not provided.I consider add such fallback at
git.c. when user use git svn, git main program will be called firstly.
git main entry will check ifGIT_ASKPASSandSSH_ASKPASS, ifSSH_ASKPASSset butGIT_ASKPASSnot set,GIT_ASKPASSwill be set asSSH_ASKPASS.Quoted 4 lines
Do you think we needs add such check at git-svn.perl ?
best regards
Frank LiInteresting question. I had never thought of moving the fallback to git.
I would have done it in the script as a localized fix but I definately see the value in aiding scripts from all having to implement this same fallback, though:
$ENV{GIT_ASKPASS} ||= $ENV{SSH_ASKPASS};
If Junio, Eric, and the git list think that this should live in git instead then by all means.
Quoted 7 lines
--
David
--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
I don't think localized fix in every scripts, third party application is the good and the trivial solution for this issue. I'm just a simple TortoiseGIT user, but I guess other GUIs, frontends suffer from this problem too.
Best Regards,
Laszlo Papp