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

Re: [PATCH] read-cache: use index state repository for trace2 logging

From
Derrick Stolee <stolee@gmail.com>
Date
Mar 27, 2026, 13:48 UTC
Message-ID
<770465fe-c38f-45a9-b1b0-0ad682a35fab@gmail.com>
In-Reply-To
<pull.2253.git.git.1774606086325.gitgitgadget@gmail.com>
On 3/27/2026 6:08 AM, Jayesh Daga via GitGitGadget wrote:
>     Robustness: The ternary fallback ensures we avoid potential NULL pointer
>     dereferences while maintaining existing logging behavior in edge cases.
> +	r = istate->repo ? istate->repo : the_repository;
If I understand correctly, it is a bug if istate->repo is NULL.

Did you try running the test suite with istate->repo as a replacement for the_repository in these tracing calls? Is there a legitimate scenario where this would be NULL?

Show 5 quoted lines
> +	trace2_data_intmax("index", r, "read/version",
>  			   istate->version);
> -	trace2_data_intmax("index", the_repository, "read/cache_nr",
> +	trace2_data_intmax("index", r, "read/cache_nr",
>  			   istate->cache_nr);

Other than that, this is a minor improvement in the right direction. I'd rather that it be more complete if you are working in this file.

There are several places where we use the_repository and there is an 'istate' right there. If this change works, then why not apply that same transformation in the other places?

There are TODO comments for many of these, including the hunk you are editing (be sure to remove these!).

There are other cases that I see in this file:
* refresh_index() uses the_repository for progress.
* tweak_untracked_cache() has a local pointer 'r' that could
  be set to istate->repo
* tweak_split_index() passes the_repository to
  repo_config_get_split_index().
* do_read_index() uses the_repository when it could use
  istate->repo.
* read_index_from() uses the_repository for tracing.
* verify_index_from() uses the_repository->hash_algo but
  has an istate->repo that could be used.
* do_write_index() has several instances.
(At this point, I stopped taking inventory.)

There are other uses of the_repository that will be harder to remove as there isn't a local istate at the time, so those aren't worth combining with this kind of effort.

If you are already working in this space, then I recommend figuring out how much we can rely on istate->repo and then apply that knowledge to these cases as separate commits:

1. Replace the uses in the trace2 calls with istate->repo
   and delete the TODO comments.
2. Replace the other uses of the_repository when an istate
   exists already.
Thanks, -Stolee
Previous: Jayesh Daga via GitGitGadgetNext: Junio C Hamano
Message 2 of 14 in “read-cache: use index state repository for trace2 logging”
  1. read-cache: use index state repository for trace2 loggingJayesh Daga via GitGitGadget, Mar 27, 2026
  2. Derrick StoleeMar 27, 2026
  3. Junio C HamanoMar 27, 2026
  4. jayesh0104Mar 28, 2026
  5. read-cache: use istate->repo for trace2 loggingJayesh Daga via GitGitGadget, Mar 28, 2026
  6. Junio C HamanoMar 28, 2026
  7. Derrick StoleeMar 29, 2026
  8. 0/2 [GSoC] read-cache: use index state repository for trace2 loggingJayesh Daga via GitGitGadget, Mar 30, 2026
  9. 1/2 repo: add paths.git_dir repo info keyjayesh0104 via GitGitGadget, Mar 30, 2026
  10. 2/2 read-cache: use istate->repo for trace2 loggingJayesh Daga via GitGitGadget, Mar 30, 2026
  11. read-cache: use istate->repo for trace2 loggingJayesh Daga via GitGitGadget, Mar 30, 2026
  12. Junio C HamanoMar 30, 2026
  13. Derrick StoleeApr 2, 2026
  14. Jayesh DagaApr 2, 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.