git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] setup_git_directory(): fix move to worktree toplevel directory

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 30, 2008, 09:15 UTC
Message-ID
<1220087732-2288-1-git-send-email-pclouds@gmail.com>

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>
---
 This is a revised version of "Preserve cwd in setup_git_directory()"
 I sent before. Hopefully this time the commit message makes it clear.
 setup.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/setup.c b/setup.c
index 6cf9094..2e3248a 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;
 	}
 
-- 
1.6.0.96.g2fad1.dirty
Message 1 of 1 in “setup_git_directory(): fix move to worktree toplevel directory”
  1. setup_git_directory(): fix move to worktree toplevel directoryNguyễn Thái Ngọc Duy, Aug 30, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.