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

Re: Bugreport - submodules are fetched twice in some cases

From
Glen Choo <chooglen@google.com>
Date
May 14, 2022, 00:15 UTC
Message-ID
<kl6la6blj7fa.fsf@chooglen-macbookpro.roam.corp.google.com>
In-Reply-To
<xmqq1qxfbqtq.fsf@gitster.g>
> FWIW, without "--all", we do not make an extra fetch at all, with
> the current code or with code as ancient as v2.5.0

Aha, the reason why I wasn't able to override "--recurse-submodules" is that I didn't notice add_options_to_argv() was setting "--recurse-submodules" for each of the 'inner' fetch-es in fetch_multiple().

So a PoC fix might look like this
----- >8 --------- >8 --------- >8 --------- >8 --------- >8 ----
diff --git a/builtin/fetch.c b/builtin/fetch.c
index e3791f09ed..d42646e68c 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1856,10 +1856,6 @@ static void add_options_to_argv(struct strvec *argv)
 		strvec_push(argv, "--force");
 	if (keep)
 		strvec_push(argv, "--keep");
-	if (recurse_submodules == RECURSE_SUBMODULES_ON)
-		strvec_push(argv, "--recurse-submodules");
-	else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
-		strvec_push(argv, "--recurse-submodules=on-demand");
 	if (tags == TAGS_SET)
 		strvec_push(argv, "--tags");
 	else if (tags == TAGS_UNSET)
@@ -1942,8 +1938,7 @@ static int fetch_multiple(struct string_list *list, int max_children)
 			return errcode;
 	}
 
-	strvec_pushl(&argv, "fetch", "--append", "--no-auto-gc",
-		     "--no-write-commit-graph", NULL);
+	strvec_pushl(&argv, "fetch", "--append", "--no-auto-gc", "--no-write-commit-graph", "--recurse-submodules=false", NULL);
 	add_options_to_argv(&argv);
 
 	if (max_children != 1 && list->nr != 1) {
@@ -2271,6 +2266,10 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 			max_children = fetch_parallel_config;
 
 		add_options_to_argv(&options);
+		if (recurse_submodules == RECURSE_SUBMODULES_ON)
+			strvec_push(&options, "--recurse-submodules");
+		else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
+			strvec_push(&options, "--recurse-submodules=on-demand");
 		result = fetch_submodules(the_repository,
 					  &options,
 					  submodule_prefix,
Previous: Glen ChooNext: Glen Choo
Message 6 of 17 in “Bugreport - submodules are fetched twice in some cases”
  1. Benedek KozmaApr 29, 2022
  2. Junio C HamanoApr 29, 2022
  3. Glen ChooApr 29, 2022
  4. Junio C HamanoApr 29, 2022
  5. Glen ChooApr 29, 2022
  6. Glen ChooMay 14, 2022
  7. Glen ChooMay 14, 2022
  8. Junio C HamanoMay 14, 2022
  9. Glen ChooMay 16, 2022
  10. Junio C HamanoMay 16, 2022
  11. Junio C HamanoMay 16, 2022
  12. fetch: do not run a redundant fetch from submoduleJunio C Hamano, May 16, 2022
  13. Glen ChooMay 16, 2022
  14. Junio C HamanoMay 16, 2022
  15. fetch: do not run a redundant fetch from submoduleJunio C Hamano, May 16, 2022
  16. Glen ChooMay 17, 2022
  17. Junio C HamanoMay 18, 2022

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.