Skip to content

Commit b643827

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 17d6c74 commit b643827

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

t/t3201-branch-contains.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ test_expect_success 'implicit --list conflicts with modification options' '
130130
131131
'
132132

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+
133142
# We want to set up a case where the walk for the tracking info
134143
# of one branch crosses the tip of another branch (and make sure
135144
# that the latter walk does not mess up our flag to see if it was

t/t7004-tag.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,9 @@ test_expect_success 'mixing incompatibles modes and options is forbidden' '
14611461
test_must_fail git tag -n 100 &&
14621462
test_must_fail git tag -l -m msg &&
14631463
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
14651467
'
14661468

14671469
# check points-at

0 commit comments

Comments
 (0)