diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Settle the snapshot v-prefix from the tag list
`compose_snapshot_prefix` dropped the leading v of a tag only when just one of the names 1.2, v1.2 and V1.2 resolved as a tag, so that the shorter snapshot name could always be traced back to one tag. Those probes went through ref lookups, and on a case-insensitive filesystem a lookup for V1.2 finds the loose file of v1.2, so every freshly made tag counted as ambiguous and kept its v. Once git packed the refs the lookups became exact and the same tag quietly changed its snapshot names. The claimants on a stripped name are now counted over the tag list itself with exact string comparison, so the answer no longer depends on how a ref is stored or on the filesystem underneath. Two tags that really differ only by the letter's case still both keep it.
Diffstat (limited to 'tests/t0110-snapshot.sh')
-rwxr-xr-xtests/t0110-snapshot.sh34
1 file changed, 34 insertions, 0 deletions
diff --git a/tests/t0110-snapshot.sh b/tests/t0110-snapshot.sh
index 9c8ce35..79fecef 100755
--- a/tests/t0110-snapshot.sh
+++ b/tests/t0110-snapshot.sh
@@ -112,4 +112,38 @@ test_expect_success UNZIP 'unzip and verify the content' '
test_line_count = 1 master/file-5
'
+# A tag named v1.0 sheds its v in the snapshot name unless dropping it would
+# merge two tags. The first tag below stays a loose ref on purpose, because on
+# a case-insensitive filesystem a ref lookup for V1.0 finds the loose v1.0
+# file, and deciding by lookups called every fresh tag ambiguous and kept its
+# v until git happened to pack the refs.
+test_expect_success 'set up a repo with a versioned tag' '
+ mkrepo repos/vtags 2 &&
+ git -C repos/vtags update-ref refs/tags/v1.0 HEAD &&
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "snapshots=tar.gz" &&
+ echo "repo.url=vtags" &&
+ echo "repo.path=$PWD/repos/vtags/.git"
+ } >vtagsrc
+'
+
+test_expect_success 'a loose v tag still sheds its v in the snapshot name' '
+ CGIT_CONFIG="$PWD/vtagsrc" QUERY_STRING="url=vtags/refs/" cgit >tmp &&
+ grep "vtags-1.0.tar.gz" tmp &&
+ ! grep "vtags-v1.0.tar.gz" tmp
+'
+
+# The second tag goes in only after the first is packed, since two loose files
+# differing in case alone cannot coexist on a case-insensitive filesystem.
+test_expect_success 'a real case collision keeps the v on both tags' '
+ git -C repos/vtags pack-refs --all &&
+ git -C repos/vtags update-ref refs/tags/V1.0 HEAD~1 &&
+ CGIT_CONFIG="$PWD/vtagsrc" QUERY_STRING="url=vtags/refs/" cgit >tmp &&
+ grep "vtags-v1.0.tar.gz" tmp &&
+ grep "vtags-V1.0.tar.gz" tmp &&
+ ! grep "vtags-1.0.tar.gz" tmp
+'
+
test_done