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

Re: [PATCH 01/12] cache-tree: remove dependency on `the_repository`

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 2, 2026, 10:23 UTC
Message-ID
<apf5HjD7IHwStiS4@pks.im>
In-Reply-To
<xmqqzey0ljcv.fsf@gitster.g>
On Tue, Sep 01, 2026 at 03:03:44PM -0700, Junio C Hamano wrote:
Show 32 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > The "cache-tree" subsystem still depends on `the_repository`. Adapt it
> > to instead use repositories provided via the context, either as a new
> > parameter or the one passed in via `struct index_state`.
> >
> > Besides getting rid of `the_repository`, this also removes the last
> > dependency on registering submodule sources with the main object
> > database. When reading gitmodules from a submodule's index we implicitly
> > read that object via `the_repository`'s object database, which is of
> > course wrong. This works though because we would then register the
> > submodule's object database with the main object database, but a later
> > patch is going to get rid of that mechanism.
> 
> As "the_repository, " is quite a long string, many lines bust our
> usual ~70 column limit, but other than that the changes look quite
> straight-forward.
> 
> We probably should make the cache_tree_fully_valid() into file scope
> static.  Your new cache_tree_fully_valid() that takes the repository
> and a cache_tree, which will be file-scope static, will gain a new
> thin wrapper around it, i.e.,
> 
>     int has_valid_cache_tree(struct index_state *istate)
>     {
> 	return cache_tree_fully_valid(istate->repo, istate->cache_tree);
>     }
> 
> Migrate the callers outside cache_tree.c file to use it; outside the
> implementation, nobody has any business talking about a subdirectory
> of any cache-tree, or any cache-tree outside the context of the istate
> it belongs to.

Yeah, I think that's a good idea indeed. But instead of introducing a new `has_valid_cache_tree()`, I think it makes more sense to just adapt the current function and introduce `cache_tree_fully_valid_recursive()` as internal function instead. That also matches the other existing interfaces like `cache_tree_fully_valid()` better.

Thanks!
Patrick
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 31 in “odb: stop registering in-memory sources”
  1. 00/12 odb: stop registering in-memory sourcesPatrick Steinhardt, Sep 1, 2026
  2. 01/12 cache-tree: remove dependency on `the_repository`Patrick Steinhardt, Sep 1, 2026
  3. Junio C HamanoSep 1, 2026
  4. Patrick SteinhardtSep 2, 2026
  5. Junio C HamanoSep 1, 2026
  6. 02/12 submodule-config: remove uses of `the_repository`Patrick Steinhardt, Sep 1, 2026
  7. 03/12 submodule-config: stop using `the_hash_algo`Patrick Steinhardt, Sep 1, 2026
  8. 04/12 submodule-config: stop registering submodule sourcesPatrick Steinhardt, Sep 1, 2026
  9. 05/12 builtin/grep: stop registering submodule ODB as sourcePatrick Steinhardt, Sep 1, 2026
  10. 06/12 odb: remove infrastructure to register submodule sourcesPatrick Steinhardt, Sep 1, 2026
  11. Junio C HamanoSep 1, 2026
  12. 07/12 tmp-objdir: drop unused function to register alternatePatrick Steinhardt, Sep 1, 2026
  13. 08/12 odb/packed: fix memory leaks when freeing sourcePatrick Steinhardt, Sep 1, 2026
  14. 09/12 builtin/multi-pack-index: refuse unknown sources with "--object-dir="Patrick Steinhardt, Sep 1, 2026
  15. 10/12 t/helper: adapt read-midx to not link ad-hoc source anymorePatrick Steinhardt, Sep 1, 2026
  16. 11/12 t/helper: stop registering alternates in "ref-store" commandPatrick Steinhardt, Sep 1, 2026
  17. 12/12 odb: remove the ability to link sources ad-hocPatrick Steinhardt, Sep 1, 2026
  18. 00/13 odb: stop registering in-memory sourcesPatrick Steinhardt, Sep 11, 2026
  19. 01/13 cache-tree: drop `the_repository` in `cache_tree_fully_valid()`Patrick Steinhardt, Sep 11, 2026
  20. 02/13 cache-tree: remove dependency on `the_repository`Patrick Steinhardt, Sep 11, 2026
  21. 03/13 submodule-config: remove uses of `the_repository`Patrick Steinhardt, Sep 11, 2026
  22. 04/13 submodule-config: stop using `the_hash_algo`Patrick Steinhardt, Sep 11, 2026
  23. 05/13 submodule-config: stop registering submodule sourcesPatrick Steinhardt, Sep 11, 2026
  24. 06/13 builtin/grep: stop registering submodule ODB as sourcePatrick Steinhardt, Sep 11, 2026
  25. 07/13 odb: remove infrastructure to register submodule sourcesPatrick Steinhardt, Sep 11, 2026
  26. 08/13 tmp-objdir: drop unused function to register alternatePatrick Steinhardt, Sep 11, 2026
  27. 09/13 odb/packed: fix memory leaks when freeing sourcePatrick Steinhardt, Sep 11, 2026
  28. 10/13 builtin/multi-pack-index: refuse unknown sources with "--object-dir="Patrick Steinhardt, Sep 11, 2026
  29. 11/13 t/helper: adapt read-midx to not link ad-hoc source anymorePatrick Steinhardt, Sep 11, 2026
  30. 12/13 t/helper: stop registering alternates in "ref-store" commandPatrick Steinhardt, Sep 11, 2026
  31. 13/13 odb: remove the ability to link sources ad-hocPatrick Steinhardt, Sep 11, 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.