Re: [PATCH v5 2/4] refs: forward and use the reference storage payload
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Feb 13, 2026, 14:45 UTC
- Message-ID
- <CAOLa=ZQdYVO8wJxs_e-6FR7x_zOJnTNTwAVm1sHv23pnDYKnug@mail.gmail.com>
- In-Reply-To
- <20260210224654.GA1837132@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 10 quoted lines
> On Mon, Feb 09, 2026 at 04:58:19PM +0100, Karthik Nayak wrote:
>
>> + if (*is_worktree) {
>> + char *wt_id = strrchr(gitdir, '/') + 1;
>> + strbuf_addf(refdir, "/worktrees/%s", wt_id);
>> + }
>
> This is another instance where the new version of glibc will complain
> about const-ness. The wt_id variable can just be marked as const.
>Thanks, will amend.
Show 9 quoted lines
> (This and the other one I pointed out are the only two cases in your > series). > > BTW, is it possible to have a gitdir string without a slash in it? I > guess not if it is absolute, but I didn't look at the caller to see if > that is always true. Anyway, I wonder if we should be checking the > result of strrchr() here. > > -Peff
Since this is called during the ref store initialization and that value is generally set via:
1. `repo->gitdir`: Which is resolved to an absolute path 2. `repo->commondir`: Which is user input, can be without slash 3. `worktree dir`: Should contain a slash 4. `submodule dir`: Should contain a slash 5. `refs migration dir`: Should contain a slash
But even with this, Gits understanding of linked worktrees are that they are in a `$gitdir/worktrees/$wt_id`. So it should be safe to do this. Nevertheless, I'll add in a check.