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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Jan 5, 2021 at 20:42 UTC
ca9a1ed969f09c8b6efc3e1d925ac1bda7370886
1 file changed
+17
-14
t/t3800-mktag.sh
+17
-14
@@ -19,6 +19,19 @@ check_verify_failure () {
19
'
20
}
21
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
+
35
###########################################################
36
# first create a commit, so we have a valid object/type
37
# for the tag.
@@ -220,9 +233,7 @@ tagger T A Gger <> 0 +0000
233
234
EOF
235
223
-test_expect_success \
224
- 'allow empty tag email' \
225
- 'git mktag <tag.sig'
236
+test_expect_mktag_success 'allow empty tag email'
237
238
############################################################
239
# 16. disallow spaces in tag email
@@ -347,9 +358,7 @@ tagger T A Gger <tagger@example.com> 1206478233 -0500
358
this line comes after an extra newline
359
EOF
360
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'
362
363
cat >tag.sig <<EOF
364
object $head
@@ -359,9 +368,7 @@ tagger T A Gger <tagger@example.com> 1206478233 -0500
368
369
EOF
370
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)'
372
373
cat >tag.sig <<EOF
374
object $head
@@ -384,10 +391,6 @@ tagger T A Gger <tagger@example.com> 1206478233 -0500
391
392
EOF
393
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'
395
396
test_done