{"thread":{"id":"22793","subject":"[PATCH 3/3] fallback SSH_ASKPASS when GIT_ASKPASS not set","startedAt":"2010-02-24T15:15:54Z","lastAt":"2010-02-25T04:17:23Z","messageCount":5,"participants":["Frank Li","Junio C Hamano","Erik Faye-Lund"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"135573","messageId":"1267024554-3288-1-git-send-email-lznuaa@gmail.com","threadId":"22793","inReplyTo":null,"subject":"[PATCH 3/3] fallback SSH_ASKPASS when GIT_ASKPASS not set","fromName":"Frank Li","fromEmail":"lznuaa@gmail.com","sentAt":"2010-02-24T15:15:54Z","receivedAt":"2010-02-24T15:15:54Z","isPatch":true,"sender":{"key":"lznuaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40642?v=4"},"body":"If GIT_ASKPASS is not set and SSH_ASKPASS set, GIT_ASKPASS will\nuse SSH_ASKPASS. If GIT_ASKPASS set and SSH_ASKPASS is not set,\nSSH_ASKPASS will use GIT_ASKPASS.\n\nSigned-off-by: Frank Li <lznuaa@gmail.com>\n---\n git.c |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 90c6daf..39e1eba 100644\n--- a/git.c\n+++ b/git.c\n@@ -54,6 +54,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n {\n \tint handled = 0;\n \n+\tif (getenv(\"GIT_ASKPASS\") && !getenv(\"SSH_ASKPASS\"))\n+\t\tsetenv(\"SSH_ASKPASS\", getenv(\"GIT_ASKPASS\"), 1);\n+\tif (!getenv(\"GIT_ASKPASS\") && getenv(\"SSH_ASKPASS\"))\n+\t\tsetenv(\"GIT_ASKPASS\", getenv(\"SSH_ASKPASS\"), 1);\n+\n \twhile (*argc > 0) {\n \t\tconst char *cmd = (*argv)[0];\n \t\tif (cmd[0] != '-')\n-- \n1.7.0.85.g37fda.dirty\n"},{"id":"135684","messageId":"40aa078e1002240734u1ef6364fp16fbce50caf575bd@mail.gmail.com","threadId":"22793","inReplyTo":"1267024554-3288-1-git-send-email-lznuaa@gmail.com","subject":"Re: [PATCH 3/3] fallback SSH_ASKPASS when GIT_ASKPASS not set","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-02-24T15:34:57Z","receivedAt":"2010-02-24T15:34:57Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Wed, Feb 24, 2010 at 4:15 PM, Frank Li <lznuaa@gmail.com> wrote:\n> If GIT_ASKPASS is not set and SSH_ASKPASS set, GIT_ASKPASS will\n> use SSH_ASKPASS. If GIT_ASKPASS set and SSH_ASKPASS is not set,\n> SSH_ASKPASS will use GIT_ASKPASS.\n>\n\nSince there's a maximum total size of the environment on Windows\n(64kib), perhaps it's better to not increase the environment-size more\nthan necessary and instead check both variables when used? I must\nadmit doing so gives me a kind of yuck-feeling, but at least it should\nalso make non-builtins (like git-svn, which AFAICT is what you're\nfixing) work consistently even if it's not called through the\ngit-wrapper...\n\n> Signed-off-by: Frank Li <lznuaa@gmail.com>\n> ---\n>  git.c |    5 +++++\n>  1 files changed, 5 insertions(+), 0 deletions(-)\n>\n> diff --git a/git.c b/git.c\n> index 90c6daf..39e1eba 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -54,6 +54,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n>  {\n>        int handled = 0;\n>\n> +       if (getenv(\"GIT_ASKPASS\") && !getenv(\"SSH_ASKPASS\"))\n> +               setenv(\"SSH_ASKPASS\", getenv(\"GIT_ASKPASS\"), 1);\n> +       if (!getenv(\"GIT_ASKPASS\") && getenv(\"SSH_ASKPASS\"))\n> +               setenv(\"GIT_ASKPASS\", getenv(\"SSH_ASKPASS\"), 1);\n> +\n>        while (*argc > 0) {\n>                const char *cmd = (*argv)[0];\n>                if (cmd[0] != '-')\n> --\n> 1.7.0.85.g37fda.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\n\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"135578","messageId":"7vocje38ll.fsf@alter.siamese.dyndns.org","threadId":"22793","inReplyTo":"1267024554-3288-1-git-send-email-lznuaa@gmail.com","subject":"Re: [PATCH 3/3] fallback SSH_ASKPASS when GIT_ASKPASS not set","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-24T16:24:22Z","receivedAt":"2010-02-24T16:24:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Frank Li <lznuaa@gmail.com> writes:\n\n> If GIT_ASKPASS is not set and SSH_ASKPASS set, GIT_ASKPASS will\n> use SSH_ASKPASS. If GIT_ASKPASS set and SSH_ASKPASS is not set,\n> SSH_ASKPASS will use GIT_ASKPASS.\n\nIf both are set and to different values, what should happen?\n\nI think the basic idea is sound, but I am not sure if we should fallback\non both ways.  If both GIT_ASKPASS and SSH_ASKPASS are set, the user is\nprobably telling us to use GIT_ASKPASS when git does something, similar to\nhow GIT_EDITOR and EDITOR interacts.\n\nSo probably the patch to implement the fallback should be more like\n\n\tif (SSH_ASKPASS is set but not GIT_ASKPASS)\n        \tset GIT_ASKPASS from SSH_ASKPASS\n\nand then the password prompter should use GIT_ASKPASS exclusively.\n\nOf course, when we _do_ spawn ssh ourselves internally in connect.c, we\nmay have to export the value of GIT_ASKPASS as SSH_ASKPASS at the call\nsite to honor the user's request to use GIT_ASKPASS while in git (that is\npart of \"use GIT_ASKPASS exclusively\").\n\nBut it feels wrong if we exported SSH_ASKPASS set from GIT_ASKPASS when\nspawning processes in other codepaths, especially if SSH_ASKPASS is set\n(or unset) differently from GIT_ASKPASS.\n\nShawn is CC'ed as git-gui currently honors only SSH_ASKPASS and this patch\nchanges the behaviour slightly.\n"},{"id":"135645","messageId":"1976ea661002241737s74e0b9d3q30ba3f6632980fa2@mail.gmail.com","threadId":"22793","inReplyTo":"7vocje38ll.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 3/3] fallback SSH_ASKPASS when GIT_ASKPASS not set","fromName":"Frank Li","fromEmail":"lznuaa@gmail.com","sentAt":"2010-02-25T01:37:07Z","receivedAt":"2010-02-25T01:37:07Z","isPatch":true,"sender":{"key":"lznuaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40642?v=4"},"body":"> So probably the patch to implement the fallback should be more like\n>\n>        if (SSH_ASKPASS is set but not GIT_ASKPASS)\n>                set GIT_ASKPASS from SSH_ASKPASS\n>\n\ndo you means just keep these?\n\n+       if (!getenv(\"GIT_ASKPASS\") && getenv(\"SSH_ASKPASS\"))\n+               setenv(\"GIT_ASKPASS\", getenv(\"SSH_ASKPASS\"), 1);\n\n\nbest regards\nFrank Li\n"},{"id":"135652","messageId":"1976ea661002242017v318ec3davb62087006d37f5e4@mail.gmail.com","threadId":"22793","inReplyTo":"40aa078e1002240734u1ef6364fp16fbce50caf575bd@mail.gmail.com","subject":"Re: [PATCH 3/3] fallback SSH_ASKPASS when GIT_ASKPASS not set","fromName":"Frank Li","fromEmail":"lznuaa@gmail.com","sentAt":"2010-02-25T04:17:23Z","receivedAt":"2010-02-25T04:17:23Z","isPatch":true,"sender":{"key":"lznuaa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40642?v=4"},"body":">\n> Since there's a maximum total size of the environment on Windows\n> (64kib), perhaps it's better to not increase the environment-size more\n> than necessary and instead check both variables when used? I must\n> admit doing so gives me a kind of yuck-feeling, but at least it should\n> also make non-builtins (like git-svn, which AFAICT is what you're\n> fixing) work consistently even if it's not called through the\n> git-wrapper...\n>\n\nGit-svn use the same way, please read first patch.\n"}]}