Re: [PATCH v6 6/6] refs: add GIT_REFERENCE_BACKEND to specify reference backend
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Feb 17, 2026, 09:32 UTC
- Message-ID
- <CAOLa=ZQFOLh6ixB4=ukPS44uE9k3-1Zw1U2bCYf+TsKyHEqLiA@mail.gmail.com>
- In-Reply-To
- <aZQXrRuX3nsnuyEw@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 38 quoted lines
>> diff --git a/refs.c b/refs.c
>> index 87ef54abd4..6b3883a325 100644
>> --- a/refs.c
>> +++ b/refs.c
>> @@ -2192,16 +2192,21 @@ int ref_store_create_on_disk(struct ref_store *refs, int flags, struct strbuf *e
>> {
>> int ret = refs->be->create_on_disk(refs, flags, err);
>>
>> - if (!ret &&
>> - ref_storage_format_by_name(refs->be->name) != REF_STORAGE_FORMAT_FILES) {
>> - struct strbuf msg = STRBUF_INIT;
>> -
>> - strbuf_addf(&msg, "this repository uses the %s format", refs->be->name);
>> - refs_create_refdir_stubs(refs->repo, refs->gitdir, msg.buf);
>> - strbuf_release(&msg);
>> + if (!ret) {
>> + /* Creation of stubs for linked worktrees are handled in the worktree code. */
>> + if (!(flags & REF_STORE_CREATE_ON_DISK_IS_WORKTREE) && refs->repo->ref_storage_payload) {
>> + refs_create_refdir_stubs(refs->repo, refs->repo->gitdir,
>> + "repository uses alternate refs storage");
>> + } else if (ref_storage_format_by_name(refs->be->name) != REF_STORAGE_FORMAT_FILES) {
>> + struct strbuf msg = STRBUF_INIT;
>> + strbuf_addf(&msg, "this repository uses the %s format", refs->be->name);
>> + refs_create_refdir_stubs(refs->repo, refs->gitdir, msg.buf);
>> + strbuf_release(&msg);
>> + }
>> }
>
> Okay, this here is the reason why you've moved the stub creation into
> the generic parts. Makes sense.
>
>>
>> return ret;
>> +
>> }
>
> There's a stray newline here.
>Will fix.
[snip]
Show 57 quoted lines
>> diff --git a/t/t1423-ref-backend.sh b/t/t1423-ref-backend.sh >> index 9912433b8c..b743c03a59 100755 >> --- a/t/t1423-ref-backend.sh >> +++ b/t/t1423-ref-backend.sh > [snip] >> +test_expect_success 'initializing repository with alt ref directory' ' >> + test_when_finished "rm -rf repo refdir" && >> + mkdir refdir && >> + BACKEND="$(test_detect_ref_format)://$(pwd)/refdir" && >> + GIT_REFERENCE_BACKEND=$BACKEND git init repo && >> + ( >> + cd repo && >> + >> + git config get extensions.refstorage >expect && >> + echo $BACKEND >actual && >> + test_cmp expect actual && >> + >> + test_commit 1 && >> + test_commit 2 && >> + test_commit 3 && >> + git refs list >out && >> + test_grep "refs/tags/1" out && >> + test_grep "refs/tags/2" out && >> + test_grep "refs/tags/3" out >> + ) >> +' > > Should we also verify that the refdir contains the data and that the > repository only contains stubs? > >> +test_expect_success 'cloning repository with alt ref directory' ' >> + test_when_finished "rm -rf source repo refdir" && >> + mkdir refdir && >> + >> + git init source && >> + test_commit -C source 1 && >> + test_commit -C source 2 && >> + test_commit -C source 3 && >> + >> + BACKEND="$(test_detect_ref_format)://$(pwd)/refdir" && >> + GIT_REFERENCE_BACKEND=$BACKEND git clone source repo && >> + >> + git -C repo config get extensions.refstorage >expect && >> + echo $BACKEND >actual && >> + test_cmp expect actual && >> + >> + git -C source for-each-ref refs/tags/ >expect && >> + git -C repo for-each-ref refs/tags/ >actual && >> + test_cmp expect actual >> +' >> + > > Same question here. > > Thanks! > > Patrick
We can verify that the repository only contains stubs, but to verify that the refdir contains the data, we'd have to add backend specific logic, I'm not sure that is the way to go.