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

Re: Bugreport - submodules are fetched twice in some cases

From
Junio C Hamano <gitster@pobox.com>
Date
May 16, 2022, 19:04 UTC
Message-ID
<xmqqwnel1eqb.fsf@gitster.g>
In-Reply-To
<xmqq4k1p2v40.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
>> The +1 fetch is redundant, so it's probably good to get rid of it
>> anyway.

Another thing I noticed is that this +1 is *not* limited to "--all". If you give a group that expands to multiple remotes, you'd take the same fetch_multiple() code path (that is why the "single liner" patch in the message I am responding to looks at the "is remote set?", which is the same condition that decides if we use fetch_one() or fetch_multiple()).

I also notice that there is a strange "optimzation" that is used after expanding a group into one or more remotes and when it turns out it was a group of one. In such a case (and only in such a case), we set "remote" and bypass the code path that uses &list.

I wonder if this "optimization" should be also used for "--all".
 builtin/fetch.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git c/builtin/fetch.c w/builtin/fetch.c
index e3791f09ed..9093455e81 100644
--- c/builtin/fetch.c
+++ w/builtin/fetch.c
@@ -2187,6 +2187,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 		else if (argc > 1)
 			die(_("fetch --all does not make sense with refspecs"));
 		(void) for_each_remote(get_one_remote_for_fetch, &list);
+		/* no point doing fetch_multiple() of one */
+		if (list.nr == 1)
+			remote = remote_get(list.items[0].string);
 	} else if (argc == 0) {
 		/* No arguments -- use default remote */
 		remote = remote_get(NULL);
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 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.