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

[PATCH v2] setup.c: use die_errno() when chdir() system call fails

From
GRGatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>
Date
Jul 6, 2026, 19:14 UTC
Message-ID
<20260706191421.94453-1-gatlavishweshwarreddy26@gmail.com>

When chdir() fails, the errno value contains the reason for the failure. Using die() instead of die_errno() loses this information, making it harder to diagnose failures. Switch to die_errno() to include the system error message in the output.

Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>
---
 setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup.c b/setup.c
index b4652651df..e2e98d1126 100644
--- a/setup.c
+++ b/setup.c
@@ -1954,13 +1954,13 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)
 		break;
 	case GIT_DIR_DISCOVERED:
 		if (dir.len < cwd.len && chdir(dir.buf))
-			die(_("cannot change to '%s'"), dir.buf);
+			die_errno(_("cannot change to '%s'"), dir.buf);
 		prefix = setup_discovered_git_dir(repo, gitdir.buf, &cwd, dir.len,
 						  &repo_fmt, nongit_ok);
 		break;
 	case GIT_DIR_BARE:
 		if (dir.len < cwd.len && chdir(dir.buf))
-			die(_("cannot change to '%s'"), dir.buf);
+			die_errno(_("cannot change to '%s'"), dir.buf);
 		prefix = setup_bare_git_dir(repo, &cwd, dir.len, &repo_fmt, nongit_ok);
 		break;
 	case GIT_DIR_HIT_CEILING:
-- 
2.54.0
Next: Junio C Hamano
Message 1 of 2 in “setup.c: use die_errno() when chdir() system call fails”
  1. setup.c: use die_errno() when chdir() system call failsGatla Vishweshwar Reddy, Jul 6, 2026
  2. Junio C HamanoJul 6, 2026

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.