aboutsummaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2008-08-30 16:15:32 +0700
committerJunio C Hamano <gitster@pobox.com>2008-08-30 23:41:12 -0700
commitbb528633b34ac9c338a7761f3e1d251e0c560ed6 (patch)
tree19f2b61ebb62c11c17e9e77026080c66ad3f2738 /setup.c
parentf83eafdd6251af29e259da8becb7610da9f3e933 (diff)
downloadgit-bb528633b34ac9c338a7761f3e1d251e0c560ed6.tar.gz
git-bb528633b34ac9c338a7761f3e1d251e0c560ed6.tar.xz
setup_git_directory(): fix move to worktree toplevel directory
When setup_git_directory() returns successfully, it is supposed to move current working directory to worktree toplevel directory. However, the code recomputing prefix inside setup_git_directory() has to move cwd back to original working directory, in order to get new prefix. After that, it should move cwd back to worktree toplevel directory as expected. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 6cf909463..2e3248a0c 100644
--- a/setup.c
+++ b/setup.c
@@ -581,6 +581,8 @@ const char *setup_git_directory(void)
if (retval && chdir(retval))
die ("Could not jump back into original cwd");
rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
+ if (rel && *rel && chdir(get_git_work_tree()))
+ die ("Could not jump to working directory");
return rel && *rel ? strcat(rel, "/") : NULL;
}