From bb528633b34ac9c338a7761f3e1d251e0c560ed6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 30 Aug 2008 16:15:32 +0700 Subject: [PATCH] setup_git_directory(): fix move to worktree toplevel directory MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- setup.c | 2 ++ 1 file changed, 2 insertions(+) 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; } -- 2.30.2