Skip to content

Commit 0c1b487

Browse files
szedergitster
authored andcommitted
t7004-tag: add version sort tests to show prerelease reordering issues
Version sort with prerelease reordering sometimes puts tagnames in the wrong order, when the common part of two compared tagnames ends with the leading character(s) of one or more configured prerelease suffixes. Add tests that demonstrate these issues. The unrelated '--format should list tags as per format given' test later uses tags matching the same prefix as the version sort tests, thus was affected by the new tags added for the new tests in this patch. Change that test to perform its checks on a different set of tags. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9ffda48 commit 0c1b487

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

t/t7004-tag.sh

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,32 @@ test_expect_success 'reverse version sort with prerelease reordering' '
15381538
test_cmp expect actual
15391539
'
15401540

1541+
test_expect_failure 'version sort with prerelease reordering and common leading character' '
1542+
test_config versionsort.prereleaseSuffix -before &&
1543+
git tag foo1.7-before1 &&
1544+
git tag foo1.7 &&
1545+
git tag foo1.7-after1 &&
1546+
git tag -l --sort=version:refname "foo1.7*" >actual &&
1547+
cat >expect <<-\EOF &&
1548+
foo1.7-before1
1549+
foo1.7
1550+
foo1.7-after1
1551+
EOF
1552+
test_cmp expect actual
1553+
'
1554+
1555+
test_expect_failure 'version sort with prerelease reordering, multiple suffixes and common leading character' '
1556+
test_config versionsort.prereleaseSuffix -before &&
1557+
git config --add versionsort.prereleaseSuffix -after &&
1558+
git tag -l --sort=version:refname "foo1.7*" >actual &&
1559+
cat >expect <<-\EOF &&
1560+
foo1.7-before1
1561+
foo1.7-after1
1562+
foo1.7
1563+
EOF
1564+
test_cmp expect actual
1565+
'
1566+
15411567
run_with_limited_stack () {
15421568
(ulimit -s 128 && "$@")
15431569
}
@@ -1566,13 +1592,11 @@ EOF"
15661592

15671593
test_expect_success '--format should list tags as per format given' '
15681594
cat >expect <<-\EOF &&
1569-
refname : refs/tags/foo1.10
1570-
refname : refs/tags/foo1.3
1571-
refname : refs/tags/foo1.6
1572-
refname : refs/tags/foo1.6-rc1
1573-
refname : refs/tags/foo1.6-rc2
1595+
refname : refs/tags/v1.0
1596+
refname : refs/tags/v1.0.1
1597+
refname : refs/tags/v1.1.3
15741598
EOF
1575-
git tag -l --format="refname : %(refname)" "foo*" >actual &&
1599+
git tag -l --format="refname : %(refname)" "v1*" >actual &&
15761600
test_cmp expect actual
15771601
'
15781602

0 commit comments

Comments
 (0)