diff options
Diffstat (limited to 'environment.c')
-rw-r--r-- | environment.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/environment.c b/environment.c index de5581fe51..d811049a7d 100644 --- a/environment.c +++ b/environment.c @@ -137,8 +137,6 @@ static int git_work_tree_initialized; */ void set_git_work_tree(const char *new_work_tree) { - if (is_bare_repository_cfg >= 0) - die("cannot set work tree after initialization"); git_work_tree_initialized = 1; free(work_tree); work_tree = xstrdup(make_absolute_path(new_work_tree)); @@ -147,6 +145,14 @@ void set_git_work_tree(const char *new_work_tree) const char *get_git_work_tree(void) { + if (startup_info && !startup_info->setup_explicit) { + if (is_bare_repository_cfg == 1) + return NULL; + if (work_tree) + is_bare_repository_cfg = 0; + return work_tree; + } + if (!git_work_tree_initialized) { work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT); /* core.bare = true overrides implicit and config work tree */ |