{"thread":{"id":"24912","subject":"[PATCHv2 0/3] GIT_ASKPASS and core.askpass","startedAt":"2010-08-30T13:36:18Z","lastAt":"2010-08-30T13:40:29Z","messageCount":4,"participants":["Knut Franke"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"149312","messageId":"201008301536.20414.k.franke@science-computing.de","threadId":"24912","inReplyTo":null,"subject":"[PATCHv2 0/3] GIT_ASKPASS and core.askpass","fromName":"Knut Franke","fromEmail":"k.franke@science-computing.de","sentAt":"2010-08-30T13:36:18Z","receivedAt":"2010-08-30T13:36:18Z","isPatch":false,"sender":{"key":"knut.franke@gmx.de","avatar":null},"body":"Hi,\n\nand thanks for the feedback so far. Here comes an updated version:\n\n\nAnselm Kruis (1):\n      Add a new option 'core.askpass'.\n\nKnut Franke (2):\n      Allow core.askpass to override SSH_ASKPASS.\n      Extend documentation of core.askpass and GIT_ASKPASS.\n\n\n Documentation/config.txt |    9 +++++++++\n Documentation/git.txt    |    7 +++++++\n cache.h                  |    1 +\n config.c                 |    3 +++\n connect.c                |    7 +++++--\n environment.c            |    1 +\n git.c                    |    3 ---\n 7 files changed, 26 insertions(+), 5 deletions(-)\n\n--\n1.7.2.1\n-- \nVorstand/Board of Management:\nDr. Bernd Finkbeiner, Dr. Roland Niemeier, \nDr. Arno Steitz, Dr. Ingrid Zech\nVorsitzender des Aufsichtsrats/\nChairman of the Supervisory Board:\nMichel Lepert\nSitz/Registered Office: Tuebingen\nRegistergericht/Registration Court: Stuttgart\nRegisternummer/Commercial Register No.: HRB 382196 \n"},{"id":"149313","messageId":"201008301538.39784.k.franke@science-computing.de","threadId":"24912","inReplyTo":"201008301536.20414.k.franke@science-computing.de","subject":"[PATCHv2 1/3] Add a new option 'core.askpass'.","fromName":"Knut Franke","fromEmail":"k.franke@science-computing.de","sentAt":"2010-08-30T13:38:38Z","receivedAt":"2010-08-30T13:38:38Z","isPatch":false,"sender":{"key":"knut.franke@gmx.de","avatar":null},"body":"From: Anselm Kruis <a.kruis@science-computing.de>\n\nSetting this option has the same effect as setting the environment variable\n'GIT_ASKPASS'.\n\nSigned-off-by: Knut Franke <k.franke@science-computing.de>\n---\n Documentation/config.txt |    6 ++++++\n cache.h                  |    1 +\n config.c                 |    3 +++\n connect.c                |    4 +++-\n environment.c            |    1 +\n 5 files changed, 14 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 05ec3fe..38678db 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -450,6 +450,12 @@ core.excludesfile::\n \tto the value of `$HOME` and \"{tilde}user/\" to the specified user's\n \thome directory.  See linkgit:gitignore[5].\n \n+core.askpass::\n+\tSome commands (e.g. svn and http interfaces) that interactively\n+\task for a password can be told to use an external program given\n+\tvia the value of this variable when it is set, and the\n+\tenvironment variable `GIT_ASKPASS` is not set.\n+\n core.editor::\n \tCommands such as `commit` and `tag` that lets you edit\n \tmessages by launching an editor uses the value of this\ndiff --git a/cache.h b/cache.h\nindex eb77e1d..608d20a 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1032,6 +1032,7 @@ extern int pager_in_use(void);\n extern int pager_use_color;\n \n extern const char *editor_program;\n+extern const char *askpass_program;\n extern const char *excludes_file;\n \n /* base85 */\ndiff --git a/config.c b/config.c\nindex cdcf583..ac55730 100644\n--- a/config.c\n+++ b/config.c\n@@ -560,6 +560,9 @@ static int git_default_core_config(const char *var, const char *value)\n \tif (!strcmp(var, \"core.editor\"))\n \t\treturn git_config_string(&editor_program, var, value);\n \n+\tif (!strcmp(var, \"core.askpass\"))\n+\t\treturn git_config_string(&askpass_program, var, value);\n+\n \tif (!strcmp(var, \"core.excludesfile\"))\n \t\treturn git_config_pathname(&excludes_file, var, value);\n \ndiff --git a/connect.c b/connect.c\nindex 02e738a..e296bfc 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -621,12 +621,14 @@ int finish_connect(struct child_process *conn)\n \n char *git_getpass(const char *prompt)\n {\n-\tchar *askpass;\n+\tconst char *askpass;\n \tstruct child_process pass;\n \tconst char *args[3];\n \tstatic struct strbuf buffer = STRBUF_INIT;\n \n \taskpass = getenv(\"GIT_ASKPASS\");\n+\tif (!askpass)\n+\t\taskpass = askpass_program;\n \n \tif (!askpass || !(*askpass))\n \t\treturn getpass(prompt);\ndiff --git a/environment.c b/environment.c\nindex 83d38d3..e7760d8 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -37,6 +37,7 @@ size_t delta_base_cache_limit = 16 * 1024 * 1024;\n const char *pager_program;\n int pager_use_color = 1;\n const char *editor_program;\n+const char *askpass_program;\n const char *excludes_file;\n enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;\n int read_replace_refs = 1;\n-- \n1.7.2.1\n\n-- \nVorstand/Board of Management:\nDr. Bernd Finkbeiner, Dr. Roland Niemeier, \nDr. Arno Steitz, Dr. Ingrid Zech\nVorsitzender des Aufsichtsrats/\nChairman of the Supervisory Board:\nMichel Lepert\nSitz/Registered Office: Tuebingen\nRegistergericht/Registration Court: Stuttgart\nRegisternummer/Commercial Register No.: HRB 382196 \n"},{"id":"149314","messageId":"201008301539.40165.k.franke@science-computing.de","threadId":"24912","inReplyTo":"201008301536.20414.k.franke@science-computing.de","subject":"[PATCHv2 2/3] Allow core.askpass to override SSH_ASKPASS.","fromName":"Knut Franke","fromEmail":"k.franke@science-computing.de","sentAt":"2010-08-30T13:39:38Z","receivedAt":"2010-08-30T13:39:38Z","isPatch":false,"sender":{"key":"knut.franke@gmx.de","avatar":null},"body":"Modify handling of the 'core.askpass' option so that it has the same effect as\nGIT_ASKPASS also if SSH_ASKPASS is set.\n\nSigned-off-by: Knut Franke <k.franke@science-computing.de>\n---\n connect.c |    3 ++-\n git.c     |    3 ---\n 2 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/connect.c b/connect.c\nindex e296bfc..3450cab 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -629,7 +629,8 @@ char *git_getpass(const char *prompt)\n \taskpass = getenv(\"GIT_ASKPASS\");\n \tif (!askpass)\n \t\taskpass = askpass_program;\n-\n+\tif (!askpass)\n+\t\taskpass = getenv(\"SSH_ASKPASS\");\n \tif (!askpass || !(*askpass))\n \t\treturn getpass(prompt);\n \ndiff --git a/git.c b/git.c\nindex 12d2952..1545257 100644\n--- a/git.c\n+++ b/git.c\n@@ -55,9 +55,6 @@ 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(\"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.2.1\n\n-- \nVorstand/Board of Management:\nDr. Bernd Finkbeiner, Dr. Roland Niemeier, \nDr. Arno Steitz, Dr. Ingrid Zech\nVorsitzender des Aufsichtsrats/\nChairman of the Supervisory Board:\nMichel Lepert\nSitz/Registered Office: Tuebingen\nRegistergericht/Registration Court: Stuttgart\nRegisternummer/Commercial Register No.: HRB 382196 \n"},{"id":"149315","messageId":"201008301540.30323.k.franke@science-computing.de","threadId":"24912","inReplyTo":"201008301536.20414.k.franke@science-computing.de","subject":"Re: [PATCHv2 3/3] Extend documentation of core.askpass and GIT_ASKPASS.","fromName":"Knut Franke","fromEmail":"k.franke@science-computing.de","sentAt":"2010-08-30T13:40:29Z","receivedAt":"2010-08-30T13:40:29Z","isPatch":false,"sender":{"key":"knut.franke@gmx.de","avatar":null},"body":"Signed-off-by: Knut Franke <k.franke@science-computing.de>\n---\n Documentation/config.txt |    7 +++++--\n Documentation/git.txt    |    7 +++++++\n 2 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 38678db..80bc815 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -453,8 +453,11 @@ core.excludesfile::\n core.askpass::\n \tSome commands (e.g. svn and http interfaces) that interactively\n \task for a password can be told to use an external program given\n-\tvia the value of this variable when it is set, and the\n-\tenvironment variable `GIT_ASKPASS` is not set.\n+\tvia the value of this variable. Can be overridden by the 'GIT_ASKPASS'\n+\tenvironment variable. If not set, fall back to the value of the\n+\t'SSH_ASKPASS' environment variable or, failing that, a simple password\n+\tprompt. The external program shall be given a suitable prompt as\n+\tcommand line argument and write the password on its STDOUT.\n \n core.editor::\n \tCommands such as `commit` and `tag` that lets you edit\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 5317893..1879746 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -638,6 +638,13 @@ Usually it is easier to configure any desired options through your\n personal `.ssh/config` file.  Please consult your ssh documentation\n for further details.\n \n+'GIT_ASKPASS'::\n+\tIf this environment variable is set, then git commands which need to\n+\tacquire passwords or passphrases (e.g. for HTTP or IMAP authentication)\n+\twill call this program with a suitable prompt as command line argument\n+\tand read the password from its STDOUT. See also the 'core.askpass'\n+\toption in linkgit:git-config[1].\n+\n 'GIT_FLUSH'::\n \tIf this environment variable is set to \"1\", then commands such\n \tas 'git blame' (in incremental mode), 'git rev-list', 'git log',\n-- \n1.7.2.1\n\n-- \nVorstand/Board of Management:\nDr. Bernd Finkbeiner, Dr. Roland Niemeier, \nDr. Arno Steitz, Dr. Ingrid Zech\nVorsitzender des Aufsichtsrats/\nChairman of the Supervisory Board:\nMichel Lepert\nSitz/Registered Office: Tuebingen\nRegistergericht/Registration Court: Stuttgart\nRegisternummer/Commercial Register No.: HRB 382196 \n"}]}