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

[PATCH] Use correct default remote for fetching in submodule.

From
MMara <mara@marabos.nl>
Date
Feb 13, 2023, 13:14 UTC
Message-ID
<623b0b8a-a5b3-408c-b924-9f88d9763b0e@app.fastmail.com>

"git submodule update" first tries a regular "git fetch" to fetch the commit, but when that doesn't retrieve the commit it wants, it tries "git fetch <remote> <commit>". For <remote>, it used the wrong default remote: the default remote of the outer repository, rather than the default remote of the submodule.

Signed-off-by: Mara Bos <mara@marabos.nl>
---
 builtin/submodule--helper.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 4c173d8b37..50b96e0b9d 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2225,7 +2225,10 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet,
 		strvec_pushf(&cp.args, "--depth=%d", depth);
 	if (oid) {
 		char *hex = oid_to_hex(oid);
-		char *remote = get_default_remote();
+		char *remote;
+		int code = get_default_remote_submodule(module_path, &remote);
+		if (code)
+			return code;

 		strvec_pushl(&cp.args, remote, hex, NULL);
 		free(remote);
--
2.39.0
Next: Eric Sunshine
Message 1 of 2 in “Use correct default remote for fetching in submodule.”
  1. Use correct default remote for fetching in submodule.Mara, Feb 13, 2023
  2. Eric SunshineFeb 13, 2023

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.