Skip to content

Commit eddc1f5

Browse files
avargitster
authored andcommitted
mktag tests: test update-ref and reachable fsck
Extend the mktag tests to pass the created bad tag through update-ref and fsck. The reason for passing it through update-ref is to guard against it having a segfault as for-each-ref did before c685450 (ref-filter: fix NULL check for parse object failure, 2021-04-01). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47c0cb1 commit eddc1f5

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

t/t3800-mktag.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ check_verify_failure () {
4444
'
4545

4646
test_expect_success "setup: $subject" '
47+
tag_ref=refs/tags/bad_tag &&
48+
4749
# Reset any leftover state from the last $subject
4850
rm -rf bad-tag &&
4951
5052
git init --bare bad-tag &&
51-
git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig
53+
bad_tag=$(git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig)
5254
'
5355

5456
test_expect_success "hash-object & fsck unreachable: $subject" '
@@ -59,6 +61,23 @@ check_verify_failure () {
5961
test_must_fail git -C bad-tag fsck
6062
fi
6163
'
64+
65+
test_expect_success "update-ref & fsck reachable: $subject" '
66+
# Make sure the earlier test created it for us
67+
git rev-parse "$bad_tag" &&
68+
69+
# The update-ref of the bad content will fail, do it
70+
# anyway to see if it segfaults
71+
test_might_fail git -C bad-tag update-ref "$tag_ref" "$bad_tag" &&
72+
73+
# Manually create the broken, we cannot do it with
74+
# update-ref
75+
echo "$bad_tag" >"bad-tag/$tag_ref" &&
76+
77+
# Unlike fsck-ing unreachable content above, this
78+
# will always fail.
79+
test_must_fail git -C bad-tag fsck
80+
'
6281
}
6382

6483
test_expect_mktag_success() {

0 commit comments

Comments
 (0)