--- environment.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/environment.c b/environment.c index de5581f..d41dcfb 100644 --- a/environment.c +++ b/environment.c @@ -153,8 +153,16 @@ const char *get_git_work_tree(void) if (!work_tree && is_bare_repository_cfg < 1) { work_tree = git_work_tree_cfg; /* make_absolute_path also normalizes the path */ - if (work_tree && !is_absolute_path(work_tree)) - work_tree = xstrdup(make_absolute_path(git_path("%s", work_tree))); + if (work_tree && !is_absolute_path(work_tree)) { + char cwd[PATH_MAX]; + if (!getcwd(cwd, PATH_MAX)) + die("Could not get current working directory"); + if (chdir(get_git_dir())) + die("Could not chdir to $GIT_DIR"); + work_tree = xstrdup(make_absolute_path(work_tree)); + if (chdir(cwd)) + die("Could not chdir to previous working directory"); + } } else if (work_tree) work_tree = xstrdup(make_absolute_path(work_tree)); git_work_tree_initialized = 1; -- 1.7.0.2.445.gcbdb3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html