]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branch 'kf/askpass-config'
authorJunio C Hamano <gitster@pobox.com>
Wed, 8 Sep 2010 16:17:01 +0000 (09:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Sep 2010 16:17:01 +0000 (09:17 -0700)
* kf/askpass-config:
  Extend documentation of core.askpass and GIT_ASKPASS.
  Allow core.askpass to override SSH_ASKPASS.
  Add a new option 'core.askpass'.

Documentation/config.txt
Documentation/git.txt
cache.h
config.c
connect.c
environment.c
git.c

index cda6721013ac3f01e7a3b6a7e770266852cef131..d294dd6dcd29bf4bad21a51011d85c7d2cf85f19 100644 (file)
@@ -450,6 +450,15 @@ core.excludesfile::
        to the value of `$HOME` and "{tilde}user/" to the specified user's
        home directory.  See linkgit:gitignore[5].
 
+core.askpass::
+       Some commands (e.g. svn and http interfaces) that interactively
+       ask for a password can be told to use an external program given
+       via the value of this variable. Can be overridden by the 'GIT_ASKPASS'
+       environment variable. If not set, fall back to the value of the
+       'SSH_ASKPASS' environment variable or, failing that, a simple password
+       prompt. The external program shall be given a suitable prompt as
+       command line argument and write the password on its STDOUT.
+
 core.editor::
        Commands such as `commit` and `tag` that lets you edit
        messages by launching an editor uses the value of this
index 93e3b07c6cdf6c580cd7dff0d973478b91178481..e341075078f4511d2a40dca0a2c8ae1d342e6b17 100644 (file)
@@ -639,6 +639,13 @@ Usually it is easier to configure any desired options through your
 personal `.ssh/config` file.  Please consult your ssh documentation
 for further details.
 
+'GIT_ASKPASS'::
+       If this environment variable is set, then git commands which need to
+       acquire passwords or passphrases (e.g. for HTTP or IMAP authentication)
+       will call this program with a suitable prompt as command line argument
+       and read the password from its STDOUT. See also the 'core.askpass'
+       option in linkgit:git-config[1].
+
 'GIT_FLUSH'::
        If this environment variable is set to "1", then commands such
        as 'git blame' (in incremental mode), 'git rev-list', 'git log',
diff --git a/cache.h b/cache.h
index abbe08303ec24c07051c5e4f789ba85393868b94..2ef2fa3a5e166d94e5e981ca7c76afad13236e7e 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1035,6 +1035,7 @@ extern int pager_in_use(void);
 extern int pager_use_color;
 
 extern const char *editor_program;
+extern const char *askpass_program;
 extern const char *excludes_file;
 
 /* base85 */
index c2c995f16df31a3553c3260f9d32e1572b1d45eb..4b0a82040e7982ab936ed52b2bb3405bc85b80f8 100644 (file)
--- a/config.c
+++ b/config.c
@@ -605,6 +605,9 @@ static int git_default_core_config(const char *var, const char *value)
        if (!strcmp(var, "core.editor"))
                return git_config_string(&editor_program, var, value);
 
+       if (!strcmp(var, "core.askpass"))
+               return git_config_string(&askpass_program, var, value);
+
        if (!strcmp(var, "core.excludesfile"))
                return git_config_pathname(&excludes_file, var, value);
 
index 02e738a0146a5c46aaf3f1d8edc3c055a99e98b9..3450cabd0e3281e0eeedeb35d331b95bf95f5afb 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -621,13 +621,16 @@ int finish_connect(struct child_process *conn)
 
 char *git_getpass(const char *prompt)
 {
-       char *askpass;
+       const char *askpass;
        struct child_process pass;
        const char *args[3];
        static struct strbuf buffer = STRBUF_INIT;
 
        askpass = getenv("GIT_ASKPASS");
-
+       if (!askpass)
+               askpass = askpass_program;
+       if (!askpass)
+               askpass = getenv("SSH_ASKPASS");
        if (!askpass || !(*askpass))
                return getpass(prompt);
 
index 9425606443241b76afd95aec02a6fa44a5a4b85d..2d0c3153791d7cceffb12f50dd5a7716b8c0a8c0 100644 (file)
@@ -37,6 +37,7 @@ size_t delta_base_cache_limit = 16 * 1024 * 1024;
 const char *pager_program;
 int pager_use_color = 1;
 const char *editor_program;
+const char *askpass_program;
 const char *excludes_file;
 enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
 int read_replace_refs = 1;
diff --git a/git.c b/git.c
index d64ab1a24d0c491e032860477e00eb27efc5383a..ce4bcfec03bb4371d01b3f39bf93764eda337ce7 100644 (file)
--- a/git.c
+++ b/git.c
@@ -56,9 +56,6 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 {
        int handled = 0;
 
-       if (!getenv("GIT_ASKPASS") && getenv("SSH_ASKPASS"))
-               setenv("GIT_ASKPASS", getenv("SSH_ASKPASS"), 1);
-
        while (*argc > 0) {
                const char *cmd = (*argv)[0];
                if (cmd[0] != '-')