Skip to content

Commit

Permalink
setup_git_directory(): fix move to worktree toplevel directory
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 31, 2008
1 parent f83eafd commit bb52863
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit bb52863

Please sign in to comment.