git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 0/3] GIT_ASKPASS and core.askpass
@ 2010-08-30 13:36 Knut Franke
  2010-08-30 13:38 ` [PATCHv2 1/3] Add a new option 'core.askpass' Knut Franke
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Knut Franke @ 2010-08-30 13:36 UTC (permalink / raw)
  To: git; +Cc: Frank Li

Hi,

and thanks for the feedback so far. Here comes an updated version:


Anselm Kruis (1):
      Add a new option 'core.askpass'.

Knut Franke (2):
      Allow core.askpass to override SSH_ASKPASS.
      Extend documentation of core.askpass and GIT_ASKPASS.


 Documentation/config.txt |    9 +++++++++
 Documentation/git.txt    |    7 +++++++
 cache.h                  |    1 +
 config.c                 |    3 +++
 connect.c                |    7 +++++--
 environment.c            |    1 +
 git.c                    |    3 ---
 7 files changed, 26 insertions(+), 5 deletions(-)

--
1.7.2.1
-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv2 1/3] Add a new option 'core.askpass'.
  2010-08-30 13:36 [PATCHv2 0/3] GIT_ASKPASS and core.askpass Knut Franke
@ 2010-08-30 13:38 ` Knut Franke
  2010-08-30 13:39 ` [PATCHv2 2/3] Allow core.askpass to override SSH_ASKPASS Knut Franke
  2010-08-30 13:40 ` [PATCHv2 3/3] Extend documentation of core.askpass and GIT_ASKPASS Knut Franke
  2 siblings, 0 replies; 4+ messages in thread
From: Knut Franke @ 2010-08-30 13:38 UTC (permalink / raw)
  To: git; +Cc: Frank Li

From: Anselm Kruis <a.kruis@science-computing.de>

Setting this option has the same effect as setting the environment variable
'GIT_ASKPASS'.

Signed-off-by: Knut Franke <k.franke@science-computing.de>
---
 Documentation/config.txt |    6 ++++++
 cache.h                  |    1 +
 config.c                 |    3 +++
 connect.c                |    4 +++-
 environment.c            |    1 +
 5 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 05ec3fe..38678db 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -450,6 +450,12 @@ 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 when it is set, and the
+	environment variable `GIT_ASKPASS` is not set.
+
 core.editor::
 	Commands such as `commit` and `tag` that lets you edit
 	messages by launching an editor uses the value of this
diff --git a/cache.h b/cache.h
index eb77e1d..608d20a 100644
--- a/cache.h
+++ b/cache.h
@@ -1032,6 +1032,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 */
diff --git a/config.c b/config.c
index cdcf583..ac55730 100644
--- a/config.c
+++ b/config.c
@@ -560,6 +560,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);
 
diff --git a/connect.c b/connect.c
index 02e738a..e296bfc 100644
--- a/connect.c
+++ b/connect.c
@@ -621,12 +621,14 @@ 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))
 		return getpass(prompt);
diff --git a/environment.c b/environment.c
index 83d38d3..e7760d8 100644
--- a/environment.c
+++ b/environment.c
@@ -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;
-- 
1.7.2.1

-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCHv2 2/3] Allow core.askpass to override SSH_ASKPASS.
  2010-08-30 13:36 [PATCHv2 0/3] GIT_ASKPASS and core.askpass Knut Franke
  2010-08-30 13:38 ` [PATCHv2 1/3] Add a new option 'core.askpass' Knut Franke
@ 2010-08-30 13:39 ` Knut Franke
  2010-08-30 13:40 ` [PATCHv2 3/3] Extend documentation of core.askpass and GIT_ASKPASS Knut Franke
  2 siblings, 0 replies; 4+ messages in thread
From: Knut Franke @ 2010-08-30 13:39 UTC (permalink / raw)
  To: git; +Cc: Frank Li

Modify handling of the 'core.askpass' option so that it has the same effect as
GIT_ASKPASS also if SSH_ASKPASS is set.

Signed-off-by: Knut Franke <k.franke@science-computing.de>
---
 connect.c |    3 ++-
 git.c     |    3 ---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/connect.c b/connect.c
index e296bfc..3450cab 100644
--- a/connect.c
+++ b/connect.c
@@ -629,7 +629,8 @@ char *git_getpass(const char *prompt)
 	askpass = getenv("GIT_ASKPASS");
 	if (!askpass)
 		askpass = askpass_program;
-
+	if (!askpass)
+		askpass = getenv("SSH_ASKPASS");
 	if (!askpass || !(*askpass))
 		return getpass(prompt);
 
diff --git a/git.c b/git.c
index 12d2952..1545257 100644
--- a/git.c
+++ b/git.c
@@ -55,9 +55,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] != '-')
-- 
1.7.2.1

-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCHv2 3/3] Extend documentation of core.askpass and GIT_ASKPASS.
  2010-08-30 13:36 [PATCHv2 0/3] GIT_ASKPASS and core.askpass Knut Franke
  2010-08-30 13:38 ` [PATCHv2 1/3] Add a new option 'core.askpass' Knut Franke
  2010-08-30 13:39 ` [PATCHv2 2/3] Allow core.askpass to override SSH_ASKPASS Knut Franke
@ 2010-08-30 13:40 ` Knut Franke
  2 siblings, 0 replies; 4+ messages in thread
From: Knut Franke @ 2010-08-30 13:40 UTC (permalink / raw)
  To: git; +Cc: Frank Li

Signed-off-by: Knut Franke <k.franke@science-computing.de>
---
 Documentation/config.txt |    7 +++++--
 Documentation/git.txt    |    7 +++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 38678db..80bc815 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -453,8 +453,11 @@ core.excludesfile::
 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 when it is set, and the
-	environment variable `GIT_ASKPASS` is not set.
+	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
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 5317893..1879746 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -638,6 +638,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',
-- 
1.7.2.1

-- 
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-30 13:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-30 13:36 [PATCHv2 0/3] GIT_ASKPASS and core.askpass Knut Franke
2010-08-30 13:38 ` [PATCHv2 1/3] Add a new option 'core.askpass' Knut Franke
2010-08-30 13:39 ` [PATCHv2 2/3] Allow core.askpass to override SSH_ASKPASS Knut Franke
2010-08-30 13:40 ` [PATCHv2 3/3] Extend documentation of core.askpass and GIT_ASKPASS Knut Franke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).