Skip to content

Commit c7aadcc

Browse files
jonathantanmygitster
authored andcommitted
fetch: delay fetch_if_missing=0 until after config
Suppose, from a repository that has ".gitmodules", we clone with --filter=blob:none: git clone --filter=blob:none --no-checkout \ https://kernel.googlesource.com/pub/scm/git/git Then we fetch: git -C git fetch This will cause a "unable to load config blob object", because the fetch_config_from_gitmodules() invocation in cmd_fetch() will attempt to load ".gitmodules" (which Git knows to exist because the client has the tree of HEAD) while fetch_if_missing is set to 0. fetch_if_missing is set to 0 too early - ".gitmodules" here should be lazily fetched. Git must set fetch_if_missing to 0 before the fetch because as part of the fetch, packfile negotiation happens (and we do not want to fetch any missing objects when checking existence of objects), but we do not need to set it so early. Move the setting of fetch_if_missing to the earliest possible point in cmd_fetch(), right before any fetching happens. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d81542e commit c7aadcc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin/fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,8 +1755,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
17551755

17561756
packet_trace_identity("fetch");
17571757

1758-
fetch_if_missing = 0;
1759-
17601758
/* Record the command line for the reflog */
17611759
strbuf_addstr(&default_rla, "fetch");
17621760
for (i = 1; i < argc; i++)
@@ -1824,6 +1822,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
18241822
}
18251823
}
18261824

1825+
fetch_if_missing = 0;
1826+
18271827
if (remote) {
18281828
if (filter_options.choice || has_promisor_remote())
18291829
fetch_one_setup_partial(remote);

0 commit comments

Comments
 (0)