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

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

From
Tian Yuchen <cat@malon.dev>
Date
Aug 16, 2026, 06:20 UTC
Message-ID
<59841e66-4361-484e-bc1f-131ea9b2d235@malon.dev>
In-Reply-To
<xmqqmrun8jeu.fsf@gitster.g>
On 8/15/26 23:58, Junio C Hamano wrote:
Show 30 quoted lines
> Tian Yuchen <cat@malon.dev> 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.
> 
Interesting topic. Refer to the git-index-pack documentation:

...Reads a packed archive (.pack) from the specified file, builds a pack index file (.idx) for it, and optionally writes a reverse-index (.rev) for the specified pack. The packed archive, together with the pack index, *can then be placed in the objects/pack/ directory of a Git repository*...

Does this clarify that the design intent is to operate a standalone .pack file, and whether or not to put it into a repository are two different things?

Thanks! yuchen
Previous: Junio C Hamano
Message 26 of 26 in “repository: move fetch_if_missing into struct repository”
  1. repository: move fetch_if_missing into struct repositoryTian Yuchen, Jul 15, 2026
  2. Junio C HamanoJul 15, 2026
  3. Tian YuchenJul 15, 2026
  4. Patrick SteinhardtJul 15, 2026
  5. Tian YuchenJul 16, 2026
  6. Junio C HamanoJul 16, 2026
  7. repository: move fetch_if_missing into struct repositoryTian Yuchen, Jul 16, 2026
  8. Tian YuchenAug 1, 2026
  9. Patrick SteinhardtAug 4, 2026
  10. Junio C HamanoAug 4, 2026
  11. Tian YuchenAug 5, 2026
  12. Tian YuchenAug 5, 2026
  13. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 7, 2026
  14. Junio C HamanoAug 7, 2026
  15. Tian YuchenAug 9, 2026
  16. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 13, 2026
  17. Junio C HamanoAug 13, 2026
  18. 0/2 repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 14, 2026
  19. 1/2 pack-objects: give fetch_if_missing call sites access to 'repo'Tian Yuchen, Aug 14, 2026
  20. Junio C HamanoAug 14, 2026
  21. Tian YuchenAug 15, 2026
  22. 2/2 repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 14, 2026
  23. Junio C HamanoAug 14, 2026
  24. repository: move fetch_if_missing into struct repositoryTian Yuchen, Aug 15, 2026
  25. Junio C HamanoAug 15, 2026
  26. Tian YuchenAug 16, 2026

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.