Re: [PATCH 2/2] refs: add GIT_REF_URI to specify reference backend and directory
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Nov 19, 2025, 23:01 UTC
- Message-ID
- <CAOLa=ZQvG+D7NwT1mW50pC6+QGc7_PSvoTA8GgK0cvDKondx8A@mail.gmail.com>
- In-Reply-To
- <CAPig+cQ1nF47Rvvm4gDks8Bzj0htzUkfR24WB8UdnJtcQTQwCA@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 25 quoted lines
> On Wed, Nov 19, 2025 at 4:49 PM Karthik Nayak <karthik.188@gmail.com> wrote: >> Git allows setting a different object directory via >> 'GIT_OBJECT_DIRECTORY', but provides no equivalent for references. >> This asymmetry makes it difficult to test different reference backends >> or use alternative reference storage locations without modifying the >> repository structure. >> >> Add a new environment variable 'GIT_REF_URI' that specifies both the >> reference backend and directory path using a URI format: >> [...] >> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> >> --- >> diff --git a/t/t1423-ref-backend.sh b/t/t1423-ref-backend.sh >> @@ -0,0 +1,109 @@ >> +test_expect_success 'empty uri provided' ' >> + test_when_finished "rm -rf repo" && >> + git init --ref-format=files repo && >> + ( >> + cd repo && >> + GIT_REF_URI="" && >> + export GIT_REF_URI && >> + ! git refs list 2>err && > > Should this (and all other tests) be using `test_must_fail` rather than `!`? >
Initially I used 'BUG()' instead of 'error()', which was wrong, but meant that I couldn't use `test_must_fail`. I've fixed that now, but this was missed. Thanks.
Show 44 quoted lines
>> + test_grep "reference backend uri is empty" err
>> + )
>> +'
>> +ref_formats="files reftable"
>> +for from_format in $ref_formats
>> +do
>> + for to_format in $ref_formats
>> + do
>> + if test "$from_format" = "$to_format"
>> + then
>> + continue
>> + fi
>> +
>> + test_expect_success 'read from other reference backend' '
>> + test_when_finished "rm -rf repo" &&
>> + git init --ref-format=files repo &&
>> + (
>> + cd repo &&
>> + test_commit 1 &&
>> + test_commit 2 &&
>> + test_commit 3 &&
>> +
>> + git refs migrate --dry-run --ref-format=reftable >out &&
>> + REFTABLE_PATH=$(cat out | sed "s/.* ${SQ}\(.*\)${SQ}/\1/") &&
>> + git refs list >expect &&
>> + GIT_REF_URI="reftable://$REFTABLE_PATH" git refs list >actual &&
>> + test_cmp expect actual
>> + )
>> + '
>> +
>> + test_expect_success 'write to other reference backend' '
>> + [...]
>> + '
>> + done
>> +done
>
> Something seems amiss here. Presumably, this nested loop wants to test
> various combinations but the `from_format` and `to_format` variables
> are never consulted in the tests; instead the tests just hardcode
> specific ref-format values.
>
> Also, if this is indeed meant to be loop-driven, then it would be
> helpful for the test titles to include the values of `$from_format`
> and `$to_format`.Indeed. I was hasty, will fix :)