@@ -149,11 +149,11 @@ test_expect_success '--force can create a tag with the name of one existing' '
149
149
tag_exists mytag'
150
150
151
151
test_expect_success ' --force is moot with a non-existing tag name' '
152
+ test_when_finished git tag -d newtag forcetag &&
152
153
git tag newtag >expect &&
153
154
git tag --force forcetag >actual &&
154
155
test_cmp expect actual
155
156
'
156
- git tag -d newtag forcetag
157
157
158
158
# deleting tags:
159
159
324
324
'
325
325
326
326
test_expect_success ' listing tags in column with column.*' '
327
- git config column.tag row &&
328
- git config column.ui dense &&
327
+ test_config column.tag row &&
328
+ test_config column.ui dense &&
329
329
COLUMNS=40 git tag -l >actual &&
330
- git config --unset column.ui &&
331
- git config --unset column.tag &&
332
330
cat >expected <<\EOF &&
333
331
a1 aa1 cba t210 t211
334
332
v0.2.1 v1.0 v1.0.1 v1.1.3
@@ -341,9 +339,8 @@ test_expect_success 'listing tag with -n --column should fail' '
341
339
'
342
340
343
341
test_expect_success ' listing tags -n in column with column.ui ignored' '
344
- git config column.ui "row dense" &&
342
+ test_config column.ui "row dense" &&
345
343
COLUMNS=40 git tag -l -n >actual &&
346
- git config --unset column.ui &&
347
344
cat >expected <<\EOF &&
348
345
a1 Foo
349
346
aa1 Foo
@@ -1227,11 +1224,10 @@ test_expect_success GPG,RFC1991 \
1227
1224
'
1228
1225
1229
1226
# try to sign with bad user.signingkey
1230
- git config user.signingkey BobTheMouse
1231
1227
test_expect_success GPG \
1232
1228
' git tag -s fails if gpg is misconfigured (bad key)' \
1233
- ' test_must_fail git tag -s -m tail tag-gpg-failure '
1234
- git config --unset user.signingkey
1229
+ ' test_config user.signingkey BobTheMouse &&
1230
+ test_must_fail git tag -s -m tail tag-gpg-failure '
1235
1231
1236
1232
# try to produce invalid signature
1237
1233
test_expect_success GPG \
@@ -1511,7 +1507,7 @@ test_expect_success 'reverse lexical sort' '
1511
1507
'
1512
1508
1513
1509
test_expect_success ' configured lexical sort' '
1514
- git config tag.sort "v:refname" &&
1510
+ test_config tag.sort "v:refname" &&
1515
1511
git tag -l "foo*" >actual &&
1516
1512
cat >expect <<-\EOF &&
1517
1513
foo1.3
@@ -1522,6 +1518,7 @@ test_expect_success 'configured lexical sort' '
1522
1518
'
1523
1519
1524
1520
test_expect_success ' option override configured sort' '
1521
+ test_config tag.sort "v:refname" &&
1525
1522
git tag -l --sort=-refname "foo*" >actual &&
1526
1523
cat >expect <<-\EOF &&
1527
1524
foo1.6
@@ -1536,13 +1533,12 @@ test_expect_success 'invalid sort parameter on command line' '
1536
1533
'
1537
1534
1538
1535
test_expect_success ' invalid sort parameter in configuratoin' '
1539
- git config tag.sort "v:notvalid" &&
1536
+ test_config tag.sort "v:notvalid" &&
1540
1537
test_must_fail git tag -l "foo*"
1541
1538
'
1542
1539
1543
1540
test_expect_success ' version sort with prerelease reordering' '
1544
- git config --unset tag.sort &&
1545
- git config versionsort.prereleaseSuffix -rc &&
1541
+ test_config versionsort.prereleaseSuffix -rc &&
1546
1542
git tag foo1.6-rc1 &&
1547
1543
git tag foo1.6-rc2 &&
1548
1544
git tag -l --sort=version:refname "foo*" >actual &&
@@ -1557,6 +1553,7 @@ test_expect_success 'version sort with prerelease reordering' '
1557
1553
'
1558
1554
1559
1555
test_expect_success ' reverse version sort with prerelease reordering' '
1556
+ test_config versionsort.prereleaseSuffix -rc &&
1560
1557
git tag -l --sort=-version:refname "foo*" >actual &&
1561
1558
cat >expect <<-\EOF &&
1562
1559
foo1.10
@@ -1568,6 +1565,103 @@ test_expect_success 'reverse version sort with prerelease reordering' '
1568
1565
test_cmp expect actual
1569
1566
'
1570
1567
1568
+ test_expect_success ' version sort with prerelease reordering and common leading character' '
1569
+ test_config versionsort.prereleaseSuffix -before &&
1570
+ git tag foo1.7-before1 &&
1571
+ git tag foo1.7 &&
1572
+ git tag foo1.7-after1 &&
1573
+ git tag -l --sort=version:refname "foo1.7*" >actual &&
1574
+ cat >expect <<-\EOF &&
1575
+ foo1.7-before1
1576
+ foo1.7
1577
+ foo1.7-after1
1578
+ EOF
1579
+ test_cmp expect actual
1580
+ '
1581
+
1582
+ test_expect_success ' version sort with prerelease reordering, multiple suffixes and common leading character' '
1583
+ test_config versionsort.prereleaseSuffix -before &&
1584
+ git config --add versionsort.prereleaseSuffix -after &&
1585
+ git tag -l --sort=version:refname "foo1.7*" >actual &&
1586
+ cat >expect <<-\EOF &&
1587
+ foo1.7-before1
1588
+ foo1.7-after1
1589
+ foo1.7
1590
+ EOF
1591
+ test_cmp expect actual
1592
+ '
1593
+
1594
+ test_expect_success ' version sort with prerelease reordering, multiple suffixes match the same tag' '
1595
+ test_config versionsort.prereleaseSuffix -bar &&
1596
+ git config --add versionsort.prereleaseSuffix -foo-baz &&
1597
+ git config --add versionsort.prereleaseSuffix -foo-bar &&
1598
+ git tag foo1.8-foo-bar &&
1599
+ git tag foo1.8-foo-baz &&
1600
+ git tag foo1.8 &&
1601
+ git tag -l --sort=version:refname "foo1.8*" >actual &&
1602
+ cat >expect <<-\EOF &&
1603
+ foo1.8-foo-baz
1604
+ foo1.8-foo-bar
1605
+ foo1.8
1606
+ EOF
1607
+ test_cmp expect actual
1608
+ '
1609
+
1610
+ test_expect_success ' version sort with prerelease reordering, multiple suffixes match starting at the same position' '
1611
+ test_config versionsort.prereleaseSuffix -pre &&
1612
+ git config --add versionsort.prereleaseSuffix -prerelease &&
1613
+ git tag foo1.9-pre1 &&
1614
+ git tag foo1.9-pre2 &&
1615
+ git tag foo1.9-prerelease1 &&
1616
+ git tag -l --sort=version:refname "foo1.9*" >actual &&
1617
+ cat >expect <<-\EOF &&
1618
+ foo1.9-pre1
1619
+ foo1.9-pre2
1620
+ foo1.9-prerelease1
1621
+ EOF
1622
+ test_cmp expect actual
1623
+ '
1624
+
1625
+ test_expect_success ' version sort with general suffix reordering' '
1626
+ test_config versionsort.suffix -alpha &&
1627
+ git config --add versionsort.suffix -beta &&
1628
+ git config --add versionsort.suffix "" &&
1629
+ git config --add versionsort.suffix -gamma &&
1630
+ git config --add versionsort.suffix -delta &&
1631
+ git tag foo1.10-alpha &&
1632
+ git tag foo1.10-beta &&
1633
+ git tag foo1.10-gamma &&
1634
+ git tag foo1.10-delta &&
1635
+ git tag foo1.10-unlisted-suffix &&
1636
+ git tag -l --sort=version:refname "foo1.10*" >actual &&
1637
+ cat >expect <<-\EOF &&
1638
+ foo1.10-alpha
1639
+ foo1.10-beta
1640
+ foo1.10
1641
+ foo1.10-unlisted-suffix
1642
+ foo1.10-gamma
1643
+ foo1.10-delta
1644
+ EOF
1645
+ test_cmp expect actual
1646
+ '
1647
+
1648
+ test_expect_success ' versionsort.suffix overrides versionsort.prereleaseSuffix' '
1649
+ test_config versionsort.suffix -before &&
1650
+ test_config versionsort.prereleaseSuffix -after &&
1651
+ git tag -l --sort=version:refname "foo1.7*" >actual &&
1652
+ cat >expect <<-\EOF &&
1653
+ foo1.7-before1
1654
+ foo1.7
1655
+ foo1.7-after1
1656
+ EOF
1657
+ test_cmp expect actual
1658
+ '
1659
+
1660
+ test_expect_success ' version sort with very long prerelease suffix' '
1661
+ test_config versionsort.prereleaseSuffix -very-looooooooooooooooooooooooong-prerelease-suffix &&
1662
+ git tag -l --sort=version:refname
1663
+ '
1664
+
1571
1665
run_with_limited_stack () {
1572
1666
(ulimit -s 128 && " $@ " )
1573
1667
}
@@ -1596,13 +1690,11 @@ EOF"
1596
1690
1597
1691
test_expect_success ' --format should list tags as per format given' '
1598
1692
cat >expect <<-\EOF &&
1599
- refname : refs/tags/foo1.10
1600
- refname : refs/tags/foo1.3
1601
- refname : refs/tags/foo1.6
1602
- refname : refs/tags/foo1.6-rc1
1603
- refname : refs/tags/foo1.6-rc2
1693
+ refname : refs/tags/v1.0
1694
+ refname : refs/tags/v1.0.1
1695
+ refname : refs/tags/v1.1.3
1604
1696
EOF
1605
- git tag -l --format="refname : %(refname)" "foo *" >actual &&
1697
+ git tag -l --format="refname : %(refname)" "v1 *" >actual &&
1606
1698
test_cmp expect actual
1607
1699
'
1608
1700
0 commit comments