From: Jonathan Nieder Date: Wed, 12 Jul 2017 00:00:42 GMT Subject: Re: [PATCH 2/3] setup: have the_repository use the_index Message-ID: <20170712000042.GC93855@aiede.mtv.corp.google.com> In-Reply-To: <20170711220408.173269-3-bmwill@google.com> Hi, Brandon Williams wrote: > Have the index state which is stored in 'the_repository' be a pointer to > the in-core instead 'the_index'. This makes it easier to begin > transitioning more parts of the code base to operate on a 'struct > repository'. > > Signed-off-by: Brandon Williams > --- > setup.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/setup.c b/setup.c > index 860507e1f..b370bf3c1 100644 > --- a/setup.c > +++ b/setup.c > @@ -1123,6 +1123,7 @@ const char *setup_git_directory_gently(int *nongit_ok) > setup_git_env(); > } > } > + the_repository->index = &the_index; I wonder if this can be done sooner. For example, does the following work? This way, 'the_repository->index == &the_index' would be an invariant that always holds, even in the early setup stage before setup_git_directory_gently has run completely. Thanks, Jonathan diff --git i/repository.c w/repository.c index edca907404..bdc1f93282 100644 --- i/repository.c +++ w/repository.c @@ -4,7 +4,7 @@ #include "submodule-config.h" /* The main repository */ -static struct repository the_repo; +static struct repository the_repo = { .index = &the_index }; struct repository *the_repository = &the_repo; static char *git_path_from_env(const char *envvar, const char *git_dir,