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

Re: [PATCH v2] read-cache: use istate->repo for trace2 logging

From
Derrick Stolee <stolee@gmail.com>
Date
Mar 29, 2026, 14:57 UTC
Message-ID
<d1afbb2c-84d2-45da-ade5-c86397bd24de@gmail.com>
In-Reply-To
<xmqqy0jbhkch.fsf@gitster.g>
On 3/28/2026 2:36 PM, Junio C Hamano wrote:
> "Jayesh Daga via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 24 quoted lines
>> -	/*
>> -	 * TODO trace2: replace "the_repository" with the actual repo instance
>> -	 * that is associated with the given "istate".
>> -	 */
>> -	trace2_data_intmax("index", the_repository, "read/version",
>> +	r=istate->repo;
> 
> Have SP on both sides of an assignment operator '=', i.e.
> 
> 	r = istate->repo;
> 
>> +	if (!r)
>> +	    BUG("istate->repo is NULL in do_read_index");
>> +	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);
> 
> Or you can do without an intermediate variable 'r'.  Replacing
> "the_repository" with "istate->repo" would make the resulting line
> shorter already, and more importantly, readers do not have to
> remember that 'r' is an alias for 'istate->repo' while reading the
> code.

And I don't think we need these BUG() statements, so I'm sorry if that was inferred from my statement. This kind of bug isn't something that a developer will stumble upon by accidentally calling the method incorrectly, but instead would be a substantial break of the index_state structure. A segfault would be enough to catch this in testing.

Have you thought about applying this pattern to the rest of the trace2 statements in this file? Or did you want review to solidify on this section first?

Thanks, -Stolee

Previous: Junio C HamanoNext: Jayesh Daga via GitGitGadget
Message 7 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.