Re: [PATCH v2 06/21] environment: make `get_git_work_tree()` accept a repository
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 12, 2024, 11:16 UTC
- Message-ID
- <ZuLNjhWtNpO6T8Bs@pks.im>
- In-Reply-To
- <wnorpwj5stwekbdvqzz6oyom5ppqhcsg3afvujslmy45r2djdb@sn6voa5d2e5v>
On Wed, Sep 11, 2024 at 10:15:06AM -0500, Justin Tobler wrote:
Show 27 quoted lines
> On 24/08/30 11:09AM, Patrick Steinhardt wrote:
> > The `get_git_work_tree()` function retrieves the path of the work tree
> > of `the_repository`. Make it accept a `struct repository` such that it
> > can work on arbitrary repositories and make it part of the repository
> > subsystem. This reduces our reliance on `the_repository` and clarifies
> > scope.
> >
> > Signed-off-by: Patrick Steinhardt <ps@pks.im>
> > ---
> [snip]
> > diff --git a/repository.c b/repository.c
> > index cdefcb4002d..92238da3d9e 100644
> > --- a/repository.c
> > +++ b/repository.c
> > @@ -126,6 +126,11 @@ const char *repo_get_graft_file(struct repository *repo)
> > return repo->graft_file;
> > }
> >
> > +const char *repo_get_work_tree(struct repository *repo)
> > +{
> > + return repo->worktree;
> > +}
> > +
>
> Now that `repo_get_work_tree()` is accepting a `struct repository`, it's
> only functioning as a simple accessor and seems somewhat unneccesary. Is
> it preferrable to keep this?I think it still makes sense to keep it, mostly because we also have accessor functions for the other paths, too. It would feel weirdly asymmetric to have `repo_get_git_dir()` but not `repo_get_work_tree()`, in my opinion.
Patrick