On 07/11, Jonathan Nieder wrote: > 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 <bmwill@xxxxxxxxxx> > > --- > > 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, I agree with your approach, though as stefan pointed out we may not be able to use the syntax just yet...but we should still be able to use the bulky old syntax for the time being. -- Brandon Williams