Thread (108 messages) 108 messages, 8 authors, 2026-02-25

Re: [PATCH 2/2] refs: add GIT_REF_URI to specify reference backend and directory

flat view

From: Eric Sunshine <hidden>
Date: 2025-11-19 22:13:31

On Wed, Nov 19, 2025 at 4:49 PM Karthik Nayak [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
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 `!`?
quoted hunk ↗ jump to hunk
+               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`.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help