git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] git: submodule honor -c credential.* from command line

From
Jeff King <peff@peff.net>
Date
Feb 25, 2016, 07:11 UTC
Message-ID
<20160225071159.GA22529@sigill.intra.peff.net>
In-Reply-To
<20160225070036.GA5654@sigill.intra.peff.net>
On Thu, Feb 25, 2016 at 02:00:36AM -0500, Jeff King wrote:
Show 7 quoted lines
> I think something like this would work:
> [...]
> but it does not seem to pass with your patch (even after I fixed up the
> weird "local" thing). I think the problem is that we ask
> submodule--helper to do the clone, and it uses local_repo_env. So in
> addition to your patch, you probably need a C version of the same thing
> which outputs to an argv_array.

Something like this (which passes my test, but I didn't think hard about it beyond that):

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 8b3320e..fa941fd 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -124,6 +124,27 @@ static int module_name(int argc, const char **argv, const char *prefix)
 
 	return 0;
 }
+
+/* this (and submodule_config_ok) should be static in the original */
+int sanitize_submodule_config(const char *, const char *, void *);
+
+static void add_submodule_repo_env(struct argv_array *out)
+{
+	const char * const *var;
+
+	for (var = local_repo_env; *var; var++) {
+		if (!strcmp(*var, CONFIG_DATA_ENVIRONMENT)) {
+			struct strbuf sanitized_config = STRBUF_INIT;
+			git_config_from_parameters(sanitize_submodule_config,
+						   &sanitized_config);
+			argv_array_pushf(out, "%s=%s", *var, sanitized_config.buf);
+			strbuf_release(&sanitized_config);
+		} else {
+			argv_array_push(out, *var);
+		}
+	}
+}
+
 static int clone_submodule(const char *path, const char *gitdir, const char *url,
 			   const char *depth, const char *reference, int quiet)
 {
@@ -145,7 +166,7 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
 	argv_array_push(&cp.args, path);
 
 	cp.git_cmd = 1;
-	cp.env = local_repo_env;
+	add_submodule_repo_env(&cp.env_array);
 	cp.no_stdin = 1;
 
 	return run_command(&cp);
Previous: Jeff KingNext: Jacob Keller
Message 10 of 14 in “git: submodule honor -c credential.* from command line”
  1. git: submodule honor -c credential.* from command lineJacob Keller, Feb 24, 2016
  2. Eric SunshineFeb 25, 2016
  3. Jeff KingFeb 25, 2016
  4. Jacob KellerFeb 25, 2016
  5. Jeff KingFeb 25, 2016
  6. Jacob KellerFeb 25, 2016
  7. Jeff KingFeb 25, 2016
  8. Jacob KellerFeb 25, 2016
  9. Jeff KingFeb 25, 2016
  10. Jeff KingFeb 25, 2016
  11. Jacob KellerFeb 25, 2016
  12. Jacob KellerFeb 25, 2016
  13. Junio C HamanoFeb 25, 2016
  14. Jacob KellerFeb 25, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.