{"thread":{"id":"65936","subject":"[PATCH v2] setup.c: use die_errno() when chdir() system call fails","startedAt":"2026-07-06T19:14:29Z","lastAt":"2026-07-06T19:37:34Z","messageCount":2,"participants":["Gatla Vishweshwar Reddy","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"547259","messageId":"20260706191421.94453-1-gatlavishweshwarreddy26@gmail.com","threadId":"65936","inReplyTo":null,"subject":"[PATCH v2] setup.c: use die_errno() when chdir() system call fails","fromName":"Gatla Vishweshwar Reddy","fromEmail":"gatlavishweshwarreddy26@gmail.com","sentAt":"2026-07-06T19:14:21Z","receivedAt":"2026-07-06T19:14:29Z","isPatch":true,"body":"When chdir() fails, the errno value contains the reason for the\nfailure. Using die() instead of die_errno() loses this information,\nmaking it harder to diagnose failures. Switch to die_errno() to\ninclude the system error message in the output.\n\nSigned-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>\n---\n setup.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex b4652651df..e2e98d1126 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -1954,13 +1954,13 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n \t\tbreak;\n \tcase GIT_DIR_DISCOVERED:\n \t\tif (dir.len < cwd.len && chdir(dir.buf))\n-\t\t\tdie(_(\"cannot change to '%s'\"), dir.buf);\n+\t\t\tdie_errno(_(\"cannot change to '%s'\"), dir.buf);\n \t\tprefix = setup_discovered_git_dir(repo, gitdir.buf, &cwd, dir.len,\n \t\t\t\t\t\t  &repo_fmt, nongit_ok);\n \t\tbreak;\n \tcase GIT_DIR_BARE:\n \t\tif (dir.len < cwd.len && chdir(dir.buf))\n-\t\t\tdie(_(\"cannot change to '%s'\"), dir.buf);\n+\t\t\tdie_errno(_(\"cannot change to '%s'\"), dir.buf);\n \t\tprefix = setup_bare_git_dir(repo, &cwd, dir.len, &repo_fmt, nongit_ok);\n \t\tbreak;\n \tcase GIT_DIR_HIT_CEILING:\n-- \n2.54.0\n\n"},{"id":"547261","messageId":"xmqq4iibc3k3.fsf@gitster.g","threadId":"65936","inReplyTo":"20260706191421.94453-1-gatlavishweshwarreddy26@gmail.com","subject":"Re: [PATCH v2] setup.c: use die_errno() when chdir() system call fails","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-07-06T19:37:32Z","receivedAt":"2026-07-06T19:37:34Z","isPatch":true,"body":"Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes:\n\nMake sure that v(N+1) patch is sent as a reply to vN patch, so that\npeople who look at vN immediately notice there is a newer iteration\nand they should spend their time on it rather than the stale one.\n\n> When chdir() fails, the errno value contains the reason for the\n> failure. Using die() instead of die_errno() loses this information,\n> making it harder to diagnose failures. Switch to die_errno() to\n> include the system error message in the output.\n>\n> Signed-off-by: Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com>\n\nPerfect.\n\n> ---\n>  setup.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n> diff --git a/setup.c b/setup.c\n> index b4652651df..e2e98d1126 100644\n> --- a/setup.c\n> +++ b/setup.c\n> @@ -1954,13 +1954,13 @@ const char *setup_git_directory_gently(struct repository *repo, int *nongit_ok)\n>  \t\tbreak;\n>  \tcase GIT_DIR_DISCOVERED:\n>  \t\tif (dir.len < cwd.len && chdir(dir.buf))\n> -\t\t\tdie(_(\"cannot change to '%s'\"), dir.buf);\n> +\t\t\tdie_errno(_(\"cannot change to '%s'\"), dir.buf);\n>  \t\tprefix = setup_discovered_git_dir(repo, gitdir.buf, &cwd, dir.len,\n>  \t\t\t\t\t\t  &repo_fmt, nongit_ok);\n>  \t\tbreak;\n>  \tcase GIT_DIR_BARE:\n>  \t\tif (dir.len < cwd.len && chdir(dir.buf))\n> -\t\t\tdie(_(\"cannot change to '%s'\"), dir.buf);\n> +\t\t\tdie_errno(_(\"cannot change to '%s'\"), dir.buf);\n>  \t\tprefix = setup_bare_git_dir(repo, &cwd, dir.len, &repo_fmt, nongit_ok);\n>  \t\tbreak;\n>  \tcase GIT_DIR_HIT_CEILING:\n\nWill queue.  Thanks.\n"}]}