1424
test_cmp expected actual
1425
"
1426
1427
+# All the --contains tests above, but with --no-contains
1428
+test_expect_success 'checking that first commit is not listed in any tag with --no-contains (hash)' "
1429
+ >expected &&
1430
+ git tag -l --no-contains $hash1 v* >actual &&
1431
+ test_cmp expected actual
1432
+"
1433
+
1434
+test_expect_success 'checking that first commit is in all tags (tag)' "
1435
+ git tag -l --no-contains v1.0 v* >actual &&
1436
+ test_cmp expected actual
1437
+"
1438
+
1439
+test_expect_success 'checking that first commit is in all tags (relative)' "
1440
+ git tag -l --no-contains HEAD~2 v* >actual &&
1441
+ test_cmp expected actual
1442
+"
1443
+
1444
cat > expected <<EOF
1445
v2.0
1446
EOF
1450
test_cmp expected actual
1451
"
1452
1453
+cat > expected <<EOF
1454
+v0.2.1
1455
+v1.0
1456
+v1.0.1
1457
+v1.1.3
1458
+EOF
1459
+
1460
+test_expect_success 'inverse of the last test, with --no-contains' "
1461
+ git tag -l --no-contains $hash2 v* >actual &&
1462
+ test_cmp expected actual
1463
+"
1464
1465
cat > expected <<EOF
1466
EOF
1470
test_cmp expected actual
1471
"
1472
1473
+cat > expected <<EOF
1474
+v0.2.1
1475
+v1.0
1476
+v1.0.1
1477
+v1.1.3
1478
+v2.0
1479
+EOF
1480
+
1481
+test_expect_success 'conversely --no-contains on the third commit lists all tags' "
1482
+ git tag -l --no-contains $hash3 v* >actual &&
1483
+ test_cmp expected actual
1484
+"
1485
+
1486
# how about a simple merge?
1487
1488
test_expect_success 'creating simple branch' '
1504
test_cmp expected actual
1505
"
1506
1507
+cat > expected <<EOF
1508
+v0.2.1
1509
+v1.0
1510
+v1.0.1
1511
+v1.1.3
1512
+v2.0
1513
+EOF
1514
+
1515
+test_expect_success 'checking that branch head with --no-contains lists all but one tag' "
1516
+ git tag -l --no-contains $hash4 v* >actual &&
1517
+ test_cmp expected actual
1518
+"
1519
+
1520
test_expect_success 'merging original branch into this branch' '
1521
git merge --strategy=ours master &&
1522
git tag v4.0
1531
test_cmp expected actual
1532
"
1533
1534
+cat > expected <<EOF
1535
+v0.2.1
1536
+v1.0
1537
+v1.0.1
1538
+v1.1.3
1539
+v2.0
1540
+v3.0
1541
+EOF
1542
+
1543
+test_expect_success 'checking that original branch head with --no-contains lists all but one tag now' "
1544
+ git tag -l --no-contains $hash3 v* >actual &&
1545
+ test_cmp expected actual
1546
+"
1547
+
1548
cat > expected <<EOF
1549
v0.2.1
1550
v1.0
1565
test_cmp expected actual
1566
'
1567
1568
+test_expect_success 'checking that initial commit is in all tags with --no-contains' "
1569
+ >expected &&
1570
+ git tag -l --no-contains $hash1 v* >actual &&
1571
+ test_cmp expected actual
1572
+"
1573
+
1574
# mixing modes and options:
1575
1576
test_expect_success 'mixing incompatibles modes and options is forbidden' '
1596
test_must_fail git tag -l -F some file &&
1597
test_must_fail git tag -v -s &&
1598
test_must_fail git tag --contains tag-tree &&
1525
- test_must_fail git tag --contains tag-blob
1599
+ test_must_fail git tag --contains tag-blob &&
1600
+ test_must_fail git tag --no-contains tag-tree &&
1601
+ test_must_fail git tag --no-contains tag-blob &&
1602
+ test_must_fail git tag --contains --no-contains
1603
'
1604
1528
-for option in --contains --merged --no-merged --points-at
1605
+for option in --contains --no-contains --merged --no-merged --points-at
1606
do
1607
test_expect_success "mixing incompatible modes with $option is forbidden" "
1608
test_must_fail git tag -d $option HEAD &&
1869
test_lazy_prereq ULIMIT_STACK_SIZE 'run_with_limited_stack true'
1870
1871
# we require ulimit, this excludes Windows
1795
-test_expect_success ULIMIT_STACK_SIZE '--contains works in a deep repo' '
1872
+test_expect_success ULIMIT_STACK_SIZE '--contains and --no-contains work in a deep repo' '
1873
>expect &&
1874
i=1 &&
1875
while test $i -lt 8000
1885
git checkout master &&
1886
git tag far-far-away HEAD^ &&
1887
run_with_limited_stack git tag --contains HEAD >actual &&
1811
- test_cmp expect actual
1888
+ test_cmp expect actual &&
1889
+ run_with_limited_stack git tag --no-contains HEAD >actual &&
1890
+ test_line_count ">" 10 actual
1891
'
1892
1893
test_expect_success '--format should list tags as per format given' '
1949
test_cmp expect actual
1950
'
1951
1952
+test_expect_success '--contains combined with --no-contains' '
1953
+ (
1954
+ git init no-contains &&
1955
+ cd no-contains &&
1956
+ test_commit v0.1 &&
1957
+ test_commit v0.2 &&
1958
+ test_commit v0.3 &&
1959
+ test_commit v0.4 &&
1960
+ test_commit v0.5 &&
1961
+ cat >expected <<-\EOF &&
1962
+ v0.2
1963
+ v0.3
1964
+ v0.4
1965
+ EOF
1966
+ git tag --contains v0.2 --no-contains v0.5 >actual &&
1967
+ test_cmp expected actual
1968
+ )
1969
+'
1970
+
1971
+# As the docs say, list tags which contain a specified *commit*. We
1972
+# don't recurse down to tags for trees or blobs pointed to by *those*
1973
+# commits.
1974
+test_expect_success 'Does --[no-]contains stop at commits? Yes!' '
1975
+ cd no-contains &&
1976
+ blob=$(git rev-parse v0.3:v0.3.t) &&
1977
+ tree=$(git rev-parse v0.3^{tree}) &&
1978
+ git tag tag-blob $blob &&
1979
+ git tag tag-tree $tree &&
1980
+ git tag --contains v0.3 >actual &&
1981
+ cat >expected <<-\EOF &&
1982
+ v0.3
1983
+ v0.4
1984
+ v0.5
1985
+ EOF
1986
+ test_cmp expected actual &&
1987
+ git tag --no-contains v0.3 >actual &&
1988
+ cat >expected <<-\EOF &&
1989
+ v0.1
1990
+ v0.2
1991
+ EOF
1992
+ test_cmp expected actual
1993
+'
1994
+
1995
test_done