ref-filter: add test for --contains on a non-commit
Change the tag test suite to test for --contains on a tree & blob. It only accepts commits and will spew out "<object> is a tree, not a commit". It's sufficient to test this just for the "tag" and "branch" commands, because it covers all the machinery shared between "branch" and "for-each-ref". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Mar 23, 2017 at 13:05 UTC
b643827b9443deadaa5804998116107953f8b42f
2 files changed
+12
-1
t/t3201-branch-contains.sh
+9
@@ -130,6 +130,15 @@ test_expect_success 'implicit --list conflicts with modification options' '
130
131
'
132
133
+test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
134
+ test_must_fail git branch --contains master^{tree} &&
135
+ blob=$(git hash-object -w --stdin <<-\EOF
136
+ Some blob
137
+ EOF
138
+ ) &&
139
+ test_must_fail git branch --contains $blob
140
+'
141
+
142
# We want to set up a case where the walk for the tracking info
143
# of one branch crosses the tip of another branch (and make sure
144
# that the latter walk does not mess up our flag to see if it was
t/t7004-tag.sh
+3
-1
@@ -1461,7 +1461,9 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '
1461
test_must_fail git tag -n 100 &&
1462
test_must_fail git tag -l -m msg &&
1463
test_must_fail git tag -l -F some file &&
1464
- test_must_fail git tag -v -s
1464
+ test_must_fail git tag -v -s &&
1465
+ test_must_fail git tag --contains tag-tree &&
1466
+ test_must_fail git tag --contains tag-blob
1467
'
1468
1469
# check points-at