diff options
Diffstat (limited to 'setup.c')
-rw-r--r-- | setup.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1091,6 +1091,20 @@ const char *setup_git_directory_gently(int *nongit_ok) startup_info->have_repository = !nongit_ok || !*nongit_ok; startup_info->prefix = prefix; + /* + * Not all paths through the setup code will call 'set_git_dir()' (which + * directly sets up the environment) so in order to guarantee that the + * environment is in a consistent state after setup, explicitly setup + * the environment if we have a repository. + * + * NEEDSWORK: currently we allow bogus GIT_DIR values to be set in some + * code paths so we also need to explicitly setup the environment if + * the user has set GIT_DIR. It may be beneficial to disallow bogus + * GIT_DIR values at some point in the future. + */ + if (startup_info->have_repository || getenv(GIT_DIR_ENVIRONMENT)) + setup_git_env(); + strbuf_release(&dir); strbuf_release(&gitdir); |