Skip to content

Commit 47c0cb1

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a748c2 commit 47c0cb1

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

t/t3800-mktag.sh

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ check_verify_failure () {
1616
message=$2 &&
1717
shift 2 &&
1818

19+
no_strict= &&
20+
fsck_obj_ok= &&
1921
no_strict= &&
2022
while test $# != 0
2123
do
2224
case "$1" in
2325
--no-strict)
2426
no_strict=yes
2527
;;
28+
--fsck-obj-ok)
29+
fsck_obj_ok=yes
30+
;;
2631
esac &&
2732
shift
2833
done &&
@@ -37,6 +42,23 @@ check_verify_failure () {
3742
git mktag --no-strict <tag.sig
3843
fi
3944
'
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+
'
4062
}
4163

4264
test_expect_mktag_success() {
@@ -183,7 +205,8 @@ tagger . <> 0 +0000
183205
EOF
184206

185207
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
187210

188211
cat >tag.sig <<EOF
189212
object $head
@@ -216,7 +239,8 @@ tagger . <> 0 +0000
216239
EOF
217240

218241
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
220244

221245
############################################################
222246
# 9.5. verify object (hash/type) check -- replacement
@@ -245,7 +269,8 @@ tagger . <> 0 +0000
245269
EOF
246270

247271
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
249274

250275
############################################################
251276
# 10. verify tag-name check
@@ -260,7 +285,8 @@ EOF
260285

261286
check_verify_failure 'verify tag-name check' \
262287
'^error:.* badTagName:' \
263-
--no-strict
288+
--no-strict \
289+
--fsck-obj-ok
264290

265291
############################################################
266292
# 11. tagger line label check #1
@@ -275,7 +301,8 @@ EOF
275301

276302
check_verify_failure '"tagger" line label check #1' \
277303
'^error:.* missingTaggerEntry:' \
278-
--no-strict
304+
--no-strict \
305+
--fsck-obj-ok
279306

280307
############################################################
281308
# 12. tagger line label check #2
@@ -291,7 +318,8 @@ EOF
291318

292319
check_verify_failure '"tagger" line label check #2' \
293320
'^error:.* missingTaggerEntry:' \
294-
--no-strict
321+
--no-strict \
322+
--fsck-obj-ok
295323

296324
############################################################
297325
# 13. allow missing tag author name like fsck
@@ -321,7 +349,8 @@ EOF
321349

322350
check_verify_failure 'disallow malformed tagger' \
323351
'^error:.* badEmail:' \
324-
--no-strict
352+
--no-strict \
353+
--fsck-obj-ok
325354

326355
############################################################
327356
# 15. allow empty tag email
@@ -446,7 +475,8 @@ EOF
446475

447476
check_verify_failure 'detect invalid header entry' \
448477
'^error:.* extraHeaderEntry:' \
449-
--no-strict
478+
--no-strict \
479+
--fsck-obj-ok
450480

451481
test_expect_success 'invalid header entry config & fsck' '
452482
test_must_fail git mktag <tag.sig &&

0 commit comments

Comments
 (0)