summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/setup.c b/setup.c
index 5fb9c54ba6..5734a1f1c1 100644
--- a/setup.c
+++ b/setup.c
@@ -369,6 +369,8 @@ static const char *setup_bare_git_dir(const char *work_tree_env,
if (!work_tree_env)
inside_work_tree = 0;
if (offset != len) {
+ if (chdir(cwd))
+ die_errno("Cannot come back to cwd");
root_len = offset_1st_component(cwd);
cwd[offset > root_len ? offset : root_len] = '\0';
set_git_dir(cwd);