setup: don't perform lazy initialization of repository state
commit73f192c991016bf88a9416cdf0e949f8b946f7e2
authorBrandon Williams <bmwill@google.com>
Tue, 20 Jun 2017 19:19:32 +0000 (20 12:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 24 Jun 2017 01:24:34 +0000 (23 18:24 -0700)
treef86acaeb5a732acfd642a9b60ca5e76d2728c292
parent25bf951381a4880c43a3d1c65e6dce651e61148f
setup: don't perform lazy initialization of repository state

Under some circumstances (bogus GIT_DIR value or the discovered gitdir
is '.git') 'setup_git_directory()' won't initialize key repository
state.  This leads to inconsistent state after running the setup code.
To account for this inconsistent state, lazy initialization is done once
a caller asks for the repository's gitdir or some other piece of
repository state.  This is confusing and can be error prone.

Instead let's tighten the expected outcome of 'setup_git_directory()'
and ensure that it initializes repository state in all cases that would
have been handled by lazy initialization.

This also lets us drop the requirement to have 'have_git_dir()' check if
the environment variable GIT_DIR was set as that will be handled by the
end of the setup code.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
environment.c
setup.c