Skip to content

Commit ca9a1ed

Browse files
avargitster
authored andcommitted
mktag tests: test "hash-object" compatibility
Change all the successful "mktag" tests to test that "hash-object" produces the same hash for the input, and that fsck passes for both. This tests e.g. that "mktag" doesn't trim its input or otherwise munge it in a way that "hash-object" doesn't. Since we're doing an "fsck --strict" here at the end let's incorporate the creation of the "mytag" name into this test, removing the special-case at the end of the file. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47c95e7 commit ca9a1ed

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

t/t3800-mktag.sh

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ check_verify_failure () {
1919
'
2020
}
2121

22+
test_expect_mktag_success() {
23+
test_expect_success "$1" '
24+
git hash-object -t tag -w --stdin <tag.sig >expected &&
25+
git fsck --strict &&
26+
27+
git mktag <tag.sig >hash &&
28+
test_cmp expected hash &&
29+
test_when_finished "git update-ref -d refs/tags/mytag $(cat hash)" &&
30+
git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) &&
31+
git fsck --strict
32+
'
33+
}
34+
2235
###########################################################
2336
# first create a commit, so we have a valid object/type
2437
# for the tag.
@@ -220,9 +233,7 @@ tagger T A Gger <> 0 +0000
220233
221234
EOF
222235

223-
test_expect_success \
224-
'allow empty tag email' \
225-
'git mktag <tag.sig'
236+
test_expect_mktag_success 'allow empty tag email'
226237

227238
############################################################
228239
# 16. disallow spaces in tag email
@@ -347,9 +358,7 @@ tagger T A Gger <[email protected]> 1206478233 -0500
347358
this line comes after an extra newline
348359
EOF
349360

350-
test_expect_success 'allow extra newlines at start of body' '
351-
git mktag <tag.sig
352-
'
361+
test_expect_mktag_success 'allow extra newlines at start of body'
353362

354363
cat >tag.sig <<EOF
355364
object $head
@@ -359,9 +368,7 @@ tagger T A Gger <[email protected]> 1206478233 -0500
359368
360369
EOF
361370

362-
test_expect_success 'require a blank line before an empty body (1)' '
363-
git mktag <tag.sig
364-
'
371+
test_expect_mktag_success 'require a blank line before an empty body (1)'
365372

366373
cat >tag.sig <<EOF
367374
object $head
@@ -384,10 +391,6 @@ tagger T A Gger <[email protected]> 1206478233 -0500
384391
385392
EOF
386393

387-
test_expect_success 'create valid tag' '
388-
git mktag <tag.sig >hash &&
389-
git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) &&
390-
git fsck --strict
391-
'
394+
test_expect_mktag_success 'create valid tag object'
392395

393396
test_done

0 commit comments

Comments
 (0)