Re: [PATCH 5/5] treewide: always have a valid "index_state.repo" member
- From
- Jeff Hostetler <git@jeffhostetler.com>
- Date
- Jan 10, 2023, 13:13 UTC
- Message-ID
- <a28f1f70-0259-e249-87e7-57dedd01de91@jeffhostetler.com>
- In-Reply-To
- <patch-5.5-b3b0e592101-20230110T060340Z-avarab@gmail.com>
On 1/10/23 1:17 AM, Ævar Arnfjörð Bjarmason wrote:
Show 20 quoted lines
> When the "repo" member was added to "the_index" in [1] the > repo_read_index() was made to populate it, but the unpopulated > "the_index" variable didn't get the same treatment. > > Let's do that in initialize_the_repository() when we set it up, and > likewise for all of the current callers initialized an empty "struct > index_state". > > This simplifies code that needs to deal with "the_index" or a custom > "struct index_state", we no longer need to second-guess this part of > the "index_state" deep in the stack. A recent example of such > second-guessing is the "istate->repo ? istate->repo : the_repository" > code in [2]. We can now simply use "istate->repo". > > For "fsmonitor-settings.c" we can remove the initialization of a NULL > "r" argument to "the_repository". This was added back in [3], and was > needed at the time for callers that would pass us the "r" from an > "istate->repo". Before this change such a change to > "fsmonitor-settings.c" would segfault all over the test suite (e.g. in > t0002-gitfile.sh).
[...]
Thanks for looking at this. Yes, it'll be nice to be able to finally depend on istate->repo not being null all over the place.
Jeff