{"thread":{"id":"22764","subject":"[PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","startedAt":"2010-02-23T11:11:03Z","lastAt":"2010-02-26T00:15:35Z","messageCount":8,"participants":["Frank Li","Laszlo Papp","David Aguilar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"135414","messageId":"1266923463-2828-1-git-send-email-lznuaa@gmail.com","threadId":"22764","inReplyTo":null,"subject":"[PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","fromName":"Frank Li","fromEmail":"lznuaa@gmail.com","sentAt":"2010-02-23T11:11:03Z","receivedAt":"2010-02-23T11:11:03Z","isPatch":true,"sender":{"key":"lznuaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40642?v=4"},"body":"Default git-svn read charactor from terminal to get password. GUI will\nwait forever because don't know password need input.\n\nSigned-off-by: Frank Li <lznuaa@gmail.com>\n---\n git-svn.perl |   27 +++++++++++++++++----------\n 1 files changed, 17 insertions(+), 10 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 265852f..f9f104e 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -3966,18 +3966,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.83.g241b9.dirty\n"},{"id":"135495","messageId":"a362e8011002231531k17725788sb45e70428c33848b@mail.gmail.com","threadId":"22764","inReplyTo":"1266923463-2828-1-git-send-email-lznuaa@gmail.com","subject":"Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","fromName":"Laszlo Papp","fromEmail":"djszapi@archlinux.us","sentAt":"2010-02-23T23:31:39Z","receivedAt":"2010-02-23T23:31:39Z","isPatch":true,"sender":{"key":"djszapi@archlinux.us","avatar":null},"body":"Nice to see someone who are interested in the solution to hack it :-)\n\nOn 2/23/10, Frank Li <lznuaa@gmail.com> wrote:\n> Default git-svn read charactor from terminal to get password. GUI will\n> wait forever because don't know password need input.\n>\n> Signed-off-by: Frank Li <lznuaa@gmail.com>\n> ---\n>  git-svn.perl |   27 +++++++++++++++++----------\n>  1 files changed, 17 insertions(+), 10 deletions(-)\n>\n> diff --git a/git-svn.perl b/git-svn.perl\n> index 265852f..f9f104e 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -3966,18 +3966,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> --\n> 1.7.0.83.g241b9.dirty\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"135524","messageId":"20100224051307.GA3232@gmail.com","threadId":"22764","inReplyTo":"1266923463-2828-1-git-send-email-lznuaa@gmail.com","subject":"Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-02-24T05:13:10Z","receivedAt":"2010-02-24T05:13:10Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Tue, Feb 23, 2010 at 07:11:03PM +0800, Frank Li wrote:\n> Default git-svn read charactor from terminal to get password. GUI will\n> wait forever because don't know password need input.\n\nWhat do you think about this message instead?\n\n-- >8 --\nSubject: [PATCH] git-svn: Support retrieving passwords with GIT_ASKPASS\n\ngit-svn reads passwords from an interactive terminal.\nThis behavior causes 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\n(see note below)\n\n\n> diff --git a/git-svn.perl b/git-svn.perl\n> index 265852f..f9f104e 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -3966,18 +3966,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\nI think Junio mentioned this in passing but I'll repeat it.\n\nMany users already have SSH_ASKPASS defined.  It would be very\nnice if we supported SSH_ASKPASS as a fallback when GIT_ASKPASS\nis not provided.\n\n\n-- \n\t\tDavid\n"},{"id":"135525","messageId":"7vtyt7gpwz.fsf@alter.siamese.dyndns.org","threadId":"22764","inReplyTo":"20100224051307.GA3232@gmail.com","subject":"Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-24T05:31:56Z","receivedAt":"2010-02-24T05:31:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n> I think Junio mentioned this in passing but I'll repeat it.\n>\n> Many users already have SSH_ASKPASS defined.  It would be very\n> nice if we supported SSH_ASKPASS as a fallback when GIT_ASKPASS\n> is not provided.\n\nThanks; I think git-gui does something similar.\n"},{"id":"135544","messageId":"1976ea661002240013j164fc875o469c0dcdf74afe0c@mail.gmail.com","threadId":"22764","inReplyTo":"20100224051307.GA3232@gmail.com","subject":"Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","fromName":"Frank Li","fromEmail":"lznuaa@gmail.com","sentAt":"2010-02-24T08:13:01Z","receivedAt":"2010-02-24T08:13:01Z","isPatch":true,"sender":{"key":"lznuaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40642?v=4"},"body":"> -- >8 --\n> Subject: [PATCH] git-svn: Support retrieving passwords with GIT_ASKPASS\n>\n> git-svn reads passwords from an interactive terminal.\n> This behavior causes 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\nOkay, I will change it.\n\n>\n> I think Junio mentioned this in passing but I'll repeat it.\n>\n> Many users already have SSH_ASKPASS defined.  It would be very\n> nice if we supported SSH_ASKPASS as a fallback when GIT_ASKPASS\n> is not provided.\n>\n\nI consider add such fallback at git.c.  when user use git svn,  git\nmain program will be called firstly.\ngit main entry will check if GIT_ASKPASS and SSH_ASKPASS, if\nSSH_ASKPASS set but GIT_ASKPASS not set,\nGIT_ASKPASS will be set as SSH_ASKPASS.\n\nDo you think we needs add such check at git-svn.perl ?\n\nbest regards\nFrank Li\n"},{"id":"135662","messageId":"20100225091500.GB2903@gmail.com","threadId":"22764","inReplyTo":"1976ea661002240013j164fc875o469c0dcdf74afe0c@mail.gmail.com","subject":"Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-02-25T09:15:01Z","receivedAt":"2010-02-25T09:15:01Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Wed, Feb 24, 2010 at 04:13:01PM +0800, Frank Li wrote:\n> \n> > Many users already have SSH_ASKPASS defined.  It would be very\n> > nice if we supported SSH_ASKPASS as a fallback when GIT_ASKPASS\n> > is not provided.\n> >\n> \n> I consider add such fallback at git.c.  when user use git svn,  git\n> main program will be called firstly.\n> git main entry will check if GIT_ASKPASS and SSH_ASKPASS, if\n> SSH_ASKPASS set but GIT_ASKPASS not set,\n> GIT_ASKPASS will be set as SSH_ASKPASS.\n> \n> Do you think we needs add such check at git-svn.perl ?\n> \n> best regards\n> Frank Li\n\nInteresting question.  I had never thought of moving the\nfallback to git.\n\nI would have done it in the script as a localized fix but\nI definately see the value in aiding scripts from\nall having to implement this same fallback, though:\n\n\t$ENV{GIT_ASKPASS} ||= $ENV{SSH_ASKPASS};\n\nIf Junio, Eric, and the git list think that this should\nlive in git instead then by all means.\n\n-- \n\t\tDavid\n"},{"id":"135681","messageId":"a362e8011002250915l7e42beel316878b60899c440@mail.gmail.com","threadId":"22764","inReplyTo":"20100225091500.GB2903@gmail.com","subject":"Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","fromName":"Laszlo Papp","fromEmail":"djszapi@archlinux.us","sentAt":"2010-02-25T17:15:21Z","receivedAt":"2010-02-25T17:15:21Z","isPatch":true,"sender":{"key":"djszapi@archlinux.us","avatar":null},"body":"On Thu, Feb 25, 2010 at 10:15 AM, David Aguilar <davvid@gmail.com> wrote:\n> On Wed, Feb 24, 2010 at 04:13:01PM +0800, Frank Li wrote:\n>>\n>> > Many users already have SSH_ASKPASS defined.  It would be very\n>> > nice if we supported SSH_ASKPASS as a fallback when GIT_ASKPASS\n>> > is not provided.\n>> >\n>>\n>> I consider add such fallback at git.c.  when user use git svn,  git\n>> main program will be called firstly.\n>> git main entry will check if GIT_ASKPASS and SSH_ASKPASS, if\n>> SSH_ASKPASS set but GIT_ASKPASS not set,\n>> GIT_ASKPASS will be set as SSH_ASKPASS.\n>>\n>> Do you think we needs add such check at git-svn.perl ?\n>>\n>> best regards\n>> Frank Li\n>\n> Interesting question.  I had never thought of moving the\n> fallback to git.\n>\n> I would have done it in the script as a localized fix but\n> I definately see the value in aiding scripts from\n> all having to implement this same fallback, though:\n>\n>        $ENV{GIT_ASKPASS} ||= $ENV{SSH_ASKPASS};\n>\n> If Junio, Eric, and the git list think that this should\n> live in git instead then by all means.\n>\n> --\n>                David\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\nI don't think localized fix in every scripts, third party application\nis the good and the trivial solution for this issue. I'm just a simple\nTortoiseGIT user, but I guess other GUIs, frontends suffer from this\nproblem too.\n\nBest Regards,\nLaszlo Papp\n"},{"id":"135708","messageId":"1976ea661002251615o2373c527y613c2e9c7b90d98e@mail.gmail.com","threadId":"22764","inReplyTo":"20100225091500.GB2903@gmail.com","subject":"Re: [PATCH 1/1] Use GIT_ASKPASS environment to launch thirdpart UI app to get password","fromName":"Frank Li","fromEmail":"lznuaa@gmail.com","sentAt":"2010-02-26T00:15:35Z","receivedAt":"2010-02-26T00:15:35Z","isPatch":true,"sender":{"key":"lznuaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40642?v=4"},"body":">\n> I would have done it in the script as a localized fix but\n> I definately see the value in aiding scripts from\n> all having to implement this same fallback, though:\n>\n>        $ENV{GIT_ASKPASS} ||= $ENV{SSH_ASKPASS};\n>\n\nAdd it at [PATCH v2 1/3] git-svn: Support retrieving passwords with GIT_ASKPASS\n"}]}