From 73f192c991016bf88a9416cdf0e949f8b946f7e2 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 20 Jun 2017 12:19:32 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- cache.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cache.h') diff --git a/cache.h b/cache.h index 96055c2229..7c81749a98 100644 --- a/cache.h +++ b/cache.h @@ -462,6 +462,8 @@ static inline enum object_type object_type(unsigned int mode) */ extern const char * const local_repo_env[]; +extern void setup_git_env(void); + /* * Returns true iff we have a configured git repository (either via * setup_git_directory, or in the environment via $GIT_DIR). -- cgit v1.2.3