{"thread":{"id":"65934","subject":"[PATCH] setup.c: use die_errno() when chdir() system call fails","startedAt":"2026-07-06T18:39:00Z","lastAt":"2026-07-06T19:35:39Z","messageCount":2,"participants":["Gatla Vishweshwar Reddy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"547257","messageId":"20260706183851.90517-1-gatlavishweshwarreddy26@gmail.com","threadId":"65934","inReplyTo":null,"subject":"[PATCH] setup.c: use die_errno() when chdir() system call fails","fromName":"Gatla Vishweshwar Reddy","fromEmail":"gatlavishweshwarreddy26@gmail.com","sentAt":"2026-07-06T18:38:51Z","receivedAt":"2026-07-06T18:39:00Z","isPatch":true,"body":"---\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":"547260","messageId":"xmqqbjcjc3na.fsf@gitster.g","threadId":"65934","inReplyTo":"20260706183851.90517-1-gatlavishweshwarreddy26@gmail.com","subject":"Re: [PATCH] setup.c: use die_errno() when chdir() system call fails","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-07-06T19:35:37Z","receivedAt":"2026-07-06T19:35:39Z","isPatch":true,"body":"Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes:\n\n> ---\n\nThe usual way to compose a log message (i.e., what the readers would\nhave seen above that three-dash line we see) of this project is to\n\n - Give an observation on how the current system works in the\n   present tense (so no need to say \"Currently X is Y\", or\n   \"Previously X was Y\" to describe the state before your change;\n   just \"X is Y\" is enough), and discuss what you perceive as a\n   problem in it.\n\n - Propose a solution (optional---often, problem description\n   trivially leads to an obvious solution in reader's minds).\n\n - Give commands to somebody editing the codebase to \"make it so\",\n   instead of saying \"This commit does X\".\n\nin this order.  And then to conclude the message, add your sign-off\n(see Documentation/SubmittingPatches:[[sign-off]]).\n\n>  setup.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n\nThe changes are trivially correct, in that you call die_errno()\nimmediately after seeing chdir() fail (which means there is no other\npotential failures that can contaminate errno---what your die_errno()\nwill report cannot be anything but what we got from chdir()).\n\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"}]}