---
setup.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/setup.c b/setup.c
index bbb430a..e8273c3 100644
--- a/setup.c
+++ b/setup.c
@@ -4,7 +4,7 @@
static int inside_git_dir = -1;
static int inside_work_tree = -1;
-static int has_core_worktree, has_core_bare;
+static int has_core_worktree, has_core_bare, has_git_dir_env;
const char *prefix_path(const char *prefix, int len, const char *path)
{@@ -460,8 +460,10 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
* validation.
*/
gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
- if (gitdirenv)
- return setup_explicit_git_dir(gitdirenv, work_tree_env, nongit_ok);
+ if (gitdirenv) {
+ has_git_dir_env = 1;
+ return setup_explicit_git_dir(gitdirenv, work_tree_env, nongit_o, nongit_ok);
+ }
else {
/* prevent get_git_work_tree() from using it because GIT_DIR is not set */
if (work_tree_env)@@ -593,6 +595,8 @@ int check_repository_format_version(const char *var, const char *value, void *cb
has_core_bare = 1;
}
} else if (strcmp(var, "core.worktree") == 0) {
+ if (!has_git_dir_env) /* only valid when GIT_DIR is set */
+ return 0;
if (!value)
return config_error_nonbool(var);
free(git_work_tree_cfg);--
1.7.0.2.445.gcbdb3