From: Junio C Hamano <gitster@pobox.com>
To: Glen Choo <chooglen@google.com>
Cc: git@vger.kernel.org, Benedek Kozma <cyberbeni@gmail.com>
Subject: Re: Bugreport - submodules are fetched twice in some cases
Date: Mon, 16 May 2022 12:04:12 -0700 [thread overview]
Message-ID: <xmqqwnel1eqb.fsf@gitster.g> (raw)
In-Reply-To: <xmqq4k1p2v40.fsf@gitster.g> (Junio C. Hamano's message of "Mon, 16 May 2022 11:25:03 -0700")
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);
next prev parent reply other threads:[~2022-05-16 19:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 14:46 Bugreport - submodules are fetched twice in some cases Benedek Kozma
2022-04-29 17:39 ` Junio C Hamano
2022-04-29 19:05 ` Glen Choo
2022-04-29 20:02 ` Junio C Hamano
2022-04-29 20:37 ` Glen Choo
2022-05-14 0:07 ` Glen Choo
2022-05-14 5:24 ` Junio C Hamano
2022-05-16 17:45 ` Glen Choo
2022-05-16 18:25 ` Junio C Hamano
2022-05-16 19:04 ` Junio C Hamano [this message]
2022-05-16 21:53 ` [PATCH] fetch: do not run a redundant fetch from submodule Junio C Hamano
2022-05-16 22:56 ` Glen Choo
2022-05-16 23:33 ` Junio C Hamano
2022-05-16 23:53 ` [PATCH v2] " Junio C Hamano
2022-05-17 16:47 ` Glen Choo
2022-05-18 15:53 ` Junio C Hamano
2022-05-14 0:15 ` Bugreport - submodules are fetched twice in some cases Glen Choo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqwnel1eqb.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=chooglen@google.com \
--cc=cyberbeni@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).