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

[PATCH 0/5] cache API: always have a "istate->repo"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jan 10, 2023, 06:17 UTC
Message-ID
<cover-0.5-00000000000-20230110T060340Z-avarab@gmail.com>

The "struct index_state" contains a "repo" member, which should be a pointer to the repository for that index, but which due to us constructing such structs on an ad-hoc basis in various places wasn't always available.

We'd thus end up with code like this, in the recent ds/omit-trailing-hash-in-index topic:

	struct repository *r = istate->repo ? istate->repo : the_repository;

Really we should be able to trust the "istate->repo", but were carrying those sorts of conditionals because our index might come from a manually constructed source, so we'd have to fall back to "the_repository".

This series changes the relvant code so the "repo" field is always non-NULL, as 5/5 here shows we had various workarounds in place for that, which can now go away.

See https://github.com/avar/git/tree/avar/do-not-lazy-populate-istate-repo for passing CI and a fetchable branch for this topic.

See https://lore.kernel.org/git/xmqqmt6vqo2w.fsf@gitster.g/ for previous discussion on this topic.

Ævar Arnfjörð Bjarmason (5):
  builtin/difftool.c: { 0 }-initialize rather than using memset()
  sparse-index.c: expand_to_path() can assume non-NULL "istate"
  sparse-index API: fix TODO, BUG() out on NULL ensure_full_index()
  read-cache.c: refactor set_new_index_sparsity() for subsequent commit
  treewide: always have a valid "index_state.repo" member
 apply.c                   |  2 +-
 builtin/difftool.c        |  4 +---
 builtin/sparse-checkout.c |  1 +
 builtin/stash.c           |  8 ++++----
 builtin/worktree.c        |  2 +-
 fsmonitor-settings.c      | 14 --------------
 fsmonitor.c               |  2 +-
 merge-recursive.c         |  2 +-
 read-cache.c              | 23 +++++++++--------------
 repository.c              |  2 ++
 revision.c                |  2 +-
 sparse-index.c            | 15 ++++-----------
 split-index.c             |  1 +
 unpack-trees.c            |  4 +++-
 14 files changed, 30 insertions(+), 52 deletions(-)
-- 
2.39.0.1195.gabc92c078c4
Next: Ævar Arnfjörð Bjarmason
Message 1 of 32 in “cache API: always have a "istate->repo"”
  1. 0/5 cache API: always have a "istate->repo"Ævar Arnfjörð Bjarmason, Jan 10, 2023
  2. 1/5 builtin/difftool.c: { 0 }-initialize rather than using memset()Ævar Arnfjörð Bjarmason, Jan 10, 2023
  3. 2/5 sparse-index.c: expand_to_path() can assume non-NULL "istate"Ævar Arnfjörð Bjarmason, Jan 10, 2023
  4. 3/5 sparse-index API: fix TODO, BUG() out on NULL ensure_full_index()Ævar Arnfjörð Bjarmason, Jan 10, 2023
  5. Philip OakleyJan 10, 2023
  6. Ævar Arnfjörð BjarmasonJan 10, 2023
  7. Derrick StoleeJan 10, 2023
  8. 4/5 read-cache.c: refactor set_new_index_sparsity() for subsequent commitÆvar Arnfjörð Bjarmason, Jan 10, 2023
  9. 5/5 treewide: always have a valid "index_state.repo" memberÆvar Arnfjörð Bjarmason, Jan 10, 2023
  10. Ævar Arnfjörð BjarmasonJan 10, 2023
  11. Jeff HostetlerJan 10, 2023
  12. Derrick StoleeJan 10, 2023
  13. Derrick StoleeJan 10, 2023
  14. 0/6 cache API: always have a "istate->repo"Ævar Arnfjörð Bjarmason, Jan 12, 2023
  15. 1/6 builtin/difftool.c: { 0 }-initialize rather than using memset()Ævar Arnfjörð Bjarmason, Jan 12, 2023
  16. 2/6 sparse-index.c: expand_to_path() can assume non-NULL "istate"Ævar Arnfjörð Bjarmason, Jan 12, 2023
  17. 3/6 sparse-index API: BUG() out on NULL ensure_full_index()Ævar Arnfjörð Bjarmason, Jan 12, 2023
  18. 4/6 read-cache.c: refactor set_new_index_sparsity() for subsequent commitÆvar Arnfjörð Bjarmason, Jan 12, 2023
  19. 5/6 cache API: add a "INDEX_STATE_INIT" macro/function, add release_index()Ævar Arnfjörð Bjarmason, Jan 12, 2023
  20. Derrick StoleeJan 12, 2023
  21. Ævar Arnfjörð BjarmasonJan 12, 2023
  22. Derrick StoleeJan 12, 2023
  23. 6/6 treewide: always have a valid "index_state.repo" memberÆvar Arnfjörð Bjarmason, Jan 12, 2023
  24. Derrick StoleeJan 12, 2023
  25. Derrick StoleeJan 12, 2023
  26. Junio C HamanoJan 13, 2023
  27. Junio C HamanoJan 13, 2023
  28. Ævar Arnfjörð BjarmasonJan 16, 2023
  29. Philip OakleyJan 16, 2023
  30. Junio C HamanoJan 16, 2023
  31. treewide: always have a valid "index_state.repo" memberÆvar Arnfjörð Bjarmason, Jan 17, 2023
  32. Derrick StoleeJan 17, 2023

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.