Subject: Re: [PATCH 5/5] treewide: always have a valid "index_state.repo" member

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Tue, 10 Jan 2023 13:24:23 +0100

On Tue, Jan 10 2023, Ævar Arnfjörð Bjarmason wrote:

> diff --git a/repository.c b/repository.c
> index 3427085fd6d..fdebc8c597c 100644
> --- a/repository.c
> +++ b/repository.c
> @@ -28,6 +28,8 @@ void initialize_the_repository(void)
>  	the_repo.remote_state = remote_state_new();
>  	the_repo.parsed_objects = parsed_object_pool_new();
>  
> +	the_index.repo = the_repository;
> +
>  	repo_set_hash_algo(&the_repo, GIT_HASH_SHA1);
>  }

It's slightly odd to have initialize_the_repository() initialize this
other variable, I did consider adding a initialize_the_variables(), and
have that call an initialize_the_repository() and an
initialize_the_index(), but deemed it not worth it for now. Perhaps
something to revisit once we're initializing more variables here.

Arguably such a split doesn't even conceptually make sense, as we're now
declaring that "the_repository" isn't fully initalized unless the
corresponding "the_index.repo" is also set, i.e. this really is part of
"the_repository" initialization.