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 c6854508808 (ref-filter: fix NULL check for parse object failure, 2021-04-01). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jun 17, 2021 at 12:42 UTC eddc1f556cd031d59b044ab655cdc591c6180e21
1 file changed +20 -1
t/t3800-mktag.sh
+20 -1
@@ -44,11 +44,13 @@ check_verify_failure () {
44 '
45
46 test_expect_success "setup: $subject" '
47 + tag_ref=refs/tags/bad_tag &&
48 +
49 # Reset any leftover state from the last $subject
50 rm -rf bad-tag &&
51
52 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)
54 '
55
56 test_expect_success "hash-object & fsck unreachable: $subject" '
@@ -59,6 +61,23 @@ check_verify_failure () {
61 test_must_fail git -C bad-tag fsck
62 fi
63 '
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 + '
81 }
82
83 test_expect_mktag_success() {