mktag tests: test hash-object --literally and unreachable fsck

Extend the mktag tests to pass the tag we've created through both hash-object --literally and fsck. This checks that fsck itself will not complain about certain invalid content if a reachable tip isn't involved. Due to how fsck works and walks the graph the failure will be different if the object is reachable, so we might succeed before we've created the 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 Jun 17, 2021 at 12:41 UTC 47c0cb1a5db27dcf1c6117158b8152d1beacc9de
1 file changed +38 -8
t/t3800-mktag.sh
+38 -8
@@ -16,6 +16,8 @@ check_verify_failure () {
16 message=$2 &&
17 shift 2 &&
18
19 + no_strict= &&
20 + fsck_obj_ok= &&
21 no_strict= &&
22 while test $# != 0
23 do
@@ -23,6 +25,9 @@ check_verify_failure () {
25 --no-strict)
26 no_strict=yes
27 ;;
28 + --fsck-obj-ok)
29 + fsck_obj_ok=yes
30 + ;;
31 esac &&
32 shift
33 done &&
@@ -37,6 +42,23 @@ check_verify_failure () {
42 git mktag --no-strict <tag.sig
43 fi
44 '
45 +
46 + test_expect_success "setup: $subject" '
47 + # Reset any leftover state from the last $subject
48 + rm -rf bad-tag &&
49 +
50 + git init --bare bad-tag &&
51 + git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig
52 + '
53 +
54 + test_expect_success "hash-object & fsck unreachable: $subject" '
55 + if test -n "$fsck_obj_ok"
56 + then
57 + git -C bad-tag fsck
58 + else
59 + test_must_fail git -C bad-tag fsck
60 + fi
61 + '
62 }
63
64 test_expect_mktag_success() {
@@ -183,7 +205,8 @@ tagger . <> 0 +0000
205 EOF
206
207 check_verify_failure 'verify object (hash/type) check -- correct type, nonexisting object' \
186 - '^fatal: could not read tagged object'
208 + '^fatal: could not read tagged object' \
209 + --fsck-obj-ok
210
211 cat >tag.sig <<EOF
212 object $head
@@ -216,7 +239,8 @@ tagger . <> 0 +0000
239 EOF
240
241 check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
219 - '^fatal: object.*tagged as.*tree.*but is.*commit'
242 + '^fatal: object.*tagged as.*tree.*but is.*commit' \
243 + --fsck-obj-ok
244
245 ############################################################
246 # 9.5. verify object (hash/type) check -- replacement
@@ -245,7 +269,8 @@ tagger . <> 0 +0000
269 EOF
270
271 check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
248 - '^fatal: object.*tagged as.*tree.*but is.*blob'
272 + '^fatal: object.*tagged as.*tree.*but is.*blob' \
273 + --fsck-obj-ok
274
275 ############################################################
276 # 10. verify tag-name check
@@ -260,7 +285,8 @@ EOF
285
286 check_verify_failure 'verify tag-name check' \
287 '^error:.* badTagName:' \
263 - --no-strict
288 + --no-strict \
289 + --fsck-obj-ok
290
291 ############################################################
292 # 11. tagger line label check #1
@@ -275,7 +301,8 @@ EOF
301
302 check_verify_failure '"tagger" line label check #1' \
303 '^error:.* missingTaggerEntry:' \
278 - --no-strict
304 + --no-strict \
305 + --fsck-obj-ok
306
307 ############################################################
308 # 12. tagger line label check #2
@@ -291,7 +318,8 @@ EOF
318
319 check_verify_failure '"tagger" line label check #2' \
320 '^error:.* missingTaggerEntry:' \
294 - --no-strict
321 + --no-strict \
322 + --fsck-obj-ok
323
324 ############################################################
325 # 13. allow missing tag author name like fsck
@@ -321,7 +349,8 @@ EOF
349
350 check_verify_failure 'disallow malformed tagger' \
351 '^error:.* badEmail:' \
324 - --no-strict
352 + --no-strict \
353 + --fsck-obj-ok
354
355 ############################################################
356 # 15. allow empty tag email
@@ -446,7 +475,8 @@ EOF
475
476 check_verify_failure 'detect invalid header entry' \
477 '^error:.* extraHeaderEntry:' \
449 - --no-strict
478 + --no-strict \
479 + --fsck-obj-ok
480
481 test_expect_success 'invalid header entry config & fsck' '
482 test_must_fail git mktag <tag.sig &&