setup: do not forget working dir from subdir of gitdir
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 5fb9c54ba6b21aab62b76602500ae2c408f9216d..5734a1f1c1f30bb2312db1a86c345e895948b75b 100644 (file)
--- 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);