{"thread":{"id":"22904","subject":"[PATCH v5 1/3] git-svn: Support retrieving passwords with GIT_ASKPASS","startedAt":"2010-03-04T14:31:13Z","lastAt":"2010-03-08T13:07:56Z","messageCount":2,"participants":["Frank Li"],"isPatch":true,"patchVersion":5,"patchTotal":3},"messages":[{"id":"136148","messageId":"1267713074-4316-1-git-send-email-lznuaa@gmail.com","threadId":"22904","inReplyTo":null,"subject":"[PATCH v5 1/3] git-svn: Support retrieving passwords with GIT_ASKPASS","fromName":"Frank Li","fromEmail":"lznuaa@gmail.com","sentAt":"2010-03-04T14:31:13Z","receivedAt":"2010-03-04T14:31:13Z","isPatch":true,"sender":{"key":"lznuaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40642?v=4"},"body":"git-svn reads passwords from an interactive terminal.\nThis behavior cause GUIs to hang waiting for git-svn to\ncomplete\n\nFix this problem by allowing a password-retrieving command\nto be specified in GIT_ASKPASS. SSH_ASKPASS is supported\nas a fallback when GIT_ASKPASS is not provided.\n\nSigned-off-by: Frank Li <lznuaa@gmail.com>\n---\n git-svn.perl |   33 +++++++++++++++++++++++----------\n 1 files changed, 23 insertions(+), 10 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 265852f..308d0df 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -31,6 +31,12 @@ if (! exists $ENV{SVN_SSH}) {\n \t}\n }\n \n+if (! exists $ENV{GIT_ASKPASS}) {\n+\tif (exists $ENV{SSH_ASKPASS}) {\n+\t\t$ENV{GIT_ASKPASS} = $ENV{SSH_ASKPASS};\n+\t}\n+}\n+\n $Git::SVN::Log::TZ = $ENV{TZ};\n $ENV{TZ} = 'UTC';\n $| = 1; # unbuffer STDOUT\n@@ -3966,18 +3972,25 @@ sub username {\n \n sub _read_password {\n \tmy ($prompt, $realm) = @_;\n-\tprint STDERR $prompt;\n-\tSTDERR->flush;\n-\trequire Term::ReadKey;\n-\tTerm::ReadKey::ReadMode('noecho');\n \tmy $password = '';\n-\twhile (defined(my $key = Term::ReadKey::ReadKey(0))) {\n-\t\tlast if $key =~ /[\\012\\015]/; # \\n\\r\n-\t\t$password .= $key;\n+\tif (exists $ENV{GIT_ASKPASS}) {\n+\t\topen(PH, \"-|\", $ENV{GIT_ASKPASS}, $prompt);\n+\t\t$password = <PH>;\n+\t\t$password =~ s/[\\012\\015]//; # \\n\\r\n+\t\tclose(PH);\n+\t} else {\n+\t\tprint STDERR $prompt;\n+\t\tSTDERR->flush;\n+\t\trequire Term::ReadKey;\n+\t\tTerm::ReadKey::ReadMode('noecho');\n+\t\twhile (defined(my $key = Term::ReadKey::ReadKey(0))) {\n+\t\t\tlast if $key =~ /[\\012\\015]/; # \\n\\r\n+\t\t\t$password .= $key;\n+\t\t}\n+\t\tTerm::ReadKey::ReadMode('restore');\n+\t\tprint STDERR \"\\n\";\n+\t\tSTDERR->flush;\n \t}\n-\tTerm::ReadKey::ReadMode('restore');\n-\tprint STDERR \"\\n\";\n-\tSTDERR->flush;\n \t$password;\n }\n \n-- \n1.7.0.86.g84fa0\n"},{"id":"136390","messageId":"1976ea661003080507o5255ca4fqd093ee9fd3240ff4@mail.gmail.com","threadId":"22904","inReplyTo":"1267713074-4316-1-git-send-email-lznuaa@gmail.com","subject":"Re: [PATCH v5 1/3] git-svn: Support retrieving passwords with GIT_ASKPASS","fromName":"Frank Li","fromEmail":"lznuaa@gmail.com","sentAt":"2010-03-08T13:07:56Z","receivedAt":"2010-03-08T13:07:56Z","isPatch":true,"sender":{"key":"lznuaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40642?v=4"},"body":"2010/3/4 Frank Li <lznuaa@gmail.com>:\n> git-svn reads passwords from an interactive terminal.\n> This behavior cause GUIs to hang waiting for git-svn to\n> complete\n>\n> Fix this problem by allowing a password-retrieving command\n> to be specified in GIT_ASKPASS. SSH_ASKPASS is supported\n> as a fallback when GIT_ASKPASS is not provided.\n>\n> Signed-off-by: Frank Li <lznuaa@gmail.com>\n> ---\n\nHow about this patch? How about this patch? is it accepted?\n"}]}