Git development
 help / color / mirror / Atom feed
* [PATCH] setup.c: use die_errno() when chdir() system call fails
@ 2026-07-06 18:38 Gatla Vishweshwar Reddy
  2026-07-06 19:35 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Gatla Vishweshwar Reddy @ 2026-07-06 18:38 UTC (permalink / raw)
  To: git; +Cc: Gatla Vishweshwar Reddy

---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] setup.c: use die_errno() when chdir() system call fails
  2026-07-06 18:38 [PATCH] setup.c: use die_errno() when chdir() system call fails Gatla Vishweshwar Reddy
@ 2026-07-06 19:35 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2026-07-06 19:35 UTC (permalink / raw)
  To: Gatla Vishweshwar Reddy; +Cc: git

Gatla Vishweshwar Reddy <gatlavishweshwarreddy26@gmail.com> writes:

> ---

The usual way to compose a log message (i.e., what the readers would
have seen above that three-dash line we see) of this project is to

 - Give an observation on how the current system works in the
   present tense (so no need to say "Currently X is Y", or
   "Previously X was Y" to describe the state before your change;
   just "X is Y" is enough), and discuss what you perceive as a
   problem in it.

 - Propose a solution (optional---often, problem description
   trivially leads to an obvious solution in reader's minds).

 - Give commands to somebody editing the codebase to "make it so",
   instead of saying "This commit does X".

in this order.  And then to conclude the message, add your sign-off
(see Documentation/SubmittingPatches:[[sign-off]]).

>  setup.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

The changes are trivially correct, in that you call die_errno()
immediately after seeing chdir() fail (which means there is no other
potential failures that can contaminate errno---what your die_errno()
will report cannot be anything but what we got from chdir()).

> 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:

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-06 19:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 18:38 [PATCH] setup.c: use die_errno() when chdir() system call fails Gatla Vishweshwar Reddy
2026-07-06 19:35 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox