Re: [PATCH 01/16] path: refactor `repo_common_path()` family of functions
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Feb 7, 2025, 06:16 UTC
- Message-ID
- <Z6WlNXbw6s4ojsiP@pks.im>
- In-Reply-To
- <CAOLa=ZRSSnqRO_=N-sVrYSRpCZkyW0KFh5=rwX0NY_VqyzKz3A@mail.gmail.com>
On Thu, Feb 06, 2025 at 03:17:12AM -0800, Karthik Nayak wrote:
Show 19 quoted lines
> Patrick Steinhardt <ps@pks.im> writes: > > [snip] > > > diff --git a/path.c b/path.c > > index 07964f5d32..273b649e00 100644 > > --- a/path.c > > +++ b/path.c > > @@ -414,7 +414,7 @@ static void strbuf_worktree_gitdir(struct strbuf *buf, > > else if (!wt->id) > > strbuf_addstr(buf, repo->commondir); > > else > > - strbuf_git_common_path(buf, repo, "worktrees/%s", wt->id); > > + repo_common_path_append(repo, buf, "worktrees/%s", wt->id); > > This is the only place we replace `strbuf_git_common_path` with > `repo_common_path_append`, whereas other places it is > `repo_common_path_replace`. I assume that is because in those places the > buf is newly initialized.
Yes, exactly. I think that it's easier to reason about to replace callsites with `_replace()` where we can. But I'm happy to adjust the approach when it's putting too much of a burden on the reviewer.
Patrick