Thread (26 messages) flat view 26 messages, 3 authors, 1d ago

Re: [PATCH v6] repository: move fetch_if_missing into struct repository

From: Junio C Hamano <hidden>
Date: 2026-08-15 15:58:52

Tian Yuchen [off-list ref] writes:
The global variable 'fetch_if_missing' controls whether a missing
object check should prompt a lazy fetch from a promisor remote.
In order to continue the libification effort, move it into
'struct repository' and initialize it to 1 by default to keep the
previous behavior.

builtin/fetch-pack.c, builtin/fsck.c, and builtin/rev-list.c are
entered via commands marked RUN_SETUP in git.c:commands[]. Their
'repo' parameter is only NULL when '-h' is given outside of a
repository, in which case either show_usage_if_asked() or
parse_options()'s own '-h' handling exits the process before
returning. We can therefore drop their UNUSED markers and assign
to 'repo' directly.

builtin/index-pack.c is entered via RUN_SETUP_GENTLY, so its
'repo' pointer can be NULL any time it is run outside of a
repository, not only with '-h'. We keep a NULL check there and fall
back to 'the_repository'.
Hmph, are there legitimate situations where we run "git index-pack"
outside a repository, or is it a user error?  Just being curious
and not a suggestion to change the established behaviour (in other
words, even if it turns out that it should be diagnosed as a user
error, we shouldn't do so in the context of changing where the
fetch_if_missing bit lives).

Other than that, this iteration looks good to me.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help