summaryrefslogtreecommitdiff
path: root/t/t3800-mktag.sh
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-01-05 19:42:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-05 22:58:29 (GMT)
commitca9a1ed969f09c8b6efc3e1d925ac1bda7370886 (patch)
tree6e915781eab9caada4779e47244c819c72bee927 /t/t3800-mktag.sh
parent47c95e77d158e4660dab25b9fdd6f4d70013b430 (diff)
downloadgit-ca9a1ed969f09c8b6efc3e1d925ac1bda7370886.zip
git-ca9a1ed969f09c8b6efc3e1d925ac1bda7370886.tar.gz
git-ca9a1ed969f09c8b6efc3e1d925ac1bda7370886.tar.bz2
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>
Diffstat (limited to 't/t3800-mktag.sh')
-rwxr-xr-xt/t3800-mktag.sh31
1 files changed, 17 insertions, 14 deletions
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index 661b62f..c100836 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh
@@ -19,6 +19,19 @@ check_verify_failure () {
'
}
+test_expect_mktag_success() {
+ test_expect_success "$1" '
+ git hash-object -t tag -w --stdin <tag.sig >expected &&
+ git fsck --strict &&
+
+ git mktag <tag.sig >hash &&
+ test_cmp expected hash &&
+ test_when_finished "git update-ref -d refs/tags/mytag $(cat hash)" &&
+ git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) &&
+ git fsck --strict
+ '
+}
+
###########################################################
# first create a commit, so we have a valid object/type
# for the tag.
@@ -220,9 +233,7 @@ tagger T A Gger <> 0 +0000
EOF
-test_expect_success \
- 'allow empty tag email' \
- 'git mktag <tag.sig'
+test_expect_mktag_success 'allow empty tag email'
############################################################
# 16. disallow spaces in tag email
@@ -347,9 +358,7 @@ tagger T A Gger <tagger@example.com> 1206478233 -0500
this line comes after an extra newline
EOF
-test_expect_success 'allow extra newlines at start of body' '
- git mktag <tag.sig
-'
+test_expect_mktag_success 'allow extra newlines at start of body'
cat >tag.sig <<EOF
object $head
@@ -359,9 +368,7 @@ tagger T A Gger <tagger@example.com> 1206478233 -0500
EOF
-test_expect_success 'require a blank line before an empty body (1)' '
- git mktag <tag.sig
-'
+test_expect_mktag_success 'require a blank line before an empty body (1)'
cat >tag.sig <<EOF
object $head
@@ -384,10 +391,6 @@ tagger T A Gger <tagger@example.com> 1206478233 -0500
EOF
-test_expect_success 'create valid tag' '
- git mktag <tag.sig >hash &&
- git update-ref refs/tags/mytag $(cat hash) $(test_oid zero) &&
- git fsck --strict
-'
+test_expect_mktag_success 'create valid tag object'
test_done