Re: [PATCH v2 01/21] environment: make `get_git_dir()` accept a repository
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 12, 2024, 11:17 UTC
- Message-ID
- <ZuLNtdd_jIbJaZZE@pks.im>
- In-Reply-To
- <CAOLa=ZQxVtFrZqFJ+Q+0ifj5h+x-7-ZE6viD9OUyNr2CvE7s-A@mail.gmail.com>
On Wed, Sep 11, 2024 at 02:12:51PM -0700, karthik nayak wrote:
Show 19 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
>
> [snip]
>
> > diff --git a/repository.c b/repository.c
> > index 9825a308993..6f43f2e8344 100644
> > --- a/repository.c
> > +++ b/repository.c
> > @@ -91,6 +91,13 @@ static void expand_base_dir(char **out, const char *in,
> > *out = xstrfmt("%s/%s", base_dir, def_in);
> > }
> >
> > +const char *repo_get_git_dir(struct repository *repo)
> > +{
> > + if (!repo->gitdir)
> > + BUG("git environment hasn't been setup");
>
> Shouldn't this message be more generic now? Since this function can be
> used with any repository?Good point indeed. I was initially worried that changing it may alter user-visible behaviour. But in theory, calls to `BUG()` should be unreachable and thus never be encountered in the wild.
Patrick