Re: [PATCH v2] setup.c: use die_errno() when chdir() system call fails
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 6, 2026, 19:37 UTC
- Message-ID
- <xmqq4iibc3k3.fsf@gitster.g>
- In-Reply-To
- <20260706191421.94453-1-gatlavishweshwarreddy26@gmail.com>
Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes:
Make sure that v(N+1) patch is sent as a reply to vN patch, so that people who look at vN immediately notice there is a newer iteration and they should spend their time on it rather than the stale one.
Show 6 quoted lines
> 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>
Perfect.
Show 23 quoted lines
> ---
> 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:Will queue. Thanks.