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

[PATCH] fetch: delay fetch_if_missing=0 until after config

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Oct 7, 2019, 18:18 UTC
Message-ID
<20191007181825.13463-1-jonathantanmy@google.com>

When running "git fetch" in a partial clone with no blobs, for example, by:

  git clone --filter=blob:none --no-checkout \
    https://kernel.googlesource.com/pub/scm/git/git
  git -C git fetch

"git fetch" will fail to load the config blob object, printing "unable to load config blob object".

This is because fetch_if_missing is set to 0 before the config is
processed. 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.
---
This is not a full solution, but this helps in the use case described in
the commit message. The full solution probably will involve teaching the
fetch mechanism to support arbitrary struct repository objects, and by
moving fetch_if_missing into the repository object. (Alternatively, we
could add the equivalent of OBJECT_INFO_SKIP_FETCH_OBJECT to functions
like parse_commit() that are used by files like negotiator/default.c, or
split up commit parsing into object reading - which already has that
flag - and commit parsing.)
---
 builtin/fetch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 24d382b2fb..865ae6677d 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1666,8 +1666,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 
 	packet_trace_identity("fetch");
 
-	fetch_if_missing = 0;
-
 	/* Record the command line for the reflog */
 	strbuf_addstr(&default_rla, "fetch");
 	for (i = 1; i < argc; i++)
@@ -1734,6 +1732,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 		}
 	}
 
+	fetch_if_missing = 0;
+
 	if (remote) {
 		if (filter_options.choice || has_promisor_remote())
 			fetch_one_setup_partial(remote);
-- 
2.23.0.581.g78d2f28ef7-goog
Next: Emily Shaffer
Message 1 of 11 in “fetch: delay fetch_if_missing=0 until after config”
  1. fetch: delay fetch_if_missing=0 until after configJonathan Tan, Oct 7, 2019
  2. Emily ShafferOct 23, 2019
  3. fetch: delay fetch_if_missing=0 until after configJonathan Tan, Oct 23, 2019
  4. Emily ShafferOct 23, 2019
  5. fetch: delay fetch_if_missing=0 until after configJonathan Tan, Oct 23, 2019
  6. Junio C HamanoOct 24, 2019
  7. Jonathan TanOct 24, 2019
  8. Junio C HamanoOct 25, 2019
  9. Jonathan TanOct 25, 2019
  10. Junio C HamanoOct 29, 2019
  11. Jonathan TanNov 1, 2019

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.