summaryrefslogtreecommitdiff
path: root/t/t3800-mktag.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t3800-mktag.sh')
-rwxr-xr-xt/t3800-mktag.sh121
1 files changed, 106 insertions, 15 deletions
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index 6275c98523..0544d58a6e 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh
@@ -12,15 +12,93 @@ test_description='git mktag: tag object verify test'
# given in the expect.pat file.
check_verify_failure () {
- test_expect_success "$1" "
- test_must_fail git mktag <tag.sig 2>message &&
- grep '$2' message &&
- if test '$3' != '--no-strict'
+ subject=$1 &&
+ message=$2 &&
+ shift 2 &&
+
+ no_strict= &&
+ fsck_obj_ok= &&
+ no_strict= &&
+ while test $# != 0
+ do
+ case "$1" in
+ --no-strict)
+ no_strict=yes
+ ;;
+ --fsck-obj-ok)
+ fsck_obj_ok=yes
+ ;;
+ esac &&
+ shift
+ done &&
+
+ test_expect_success "fail with [--[no-]strict]: $subject" '
+ test_must_fail git mktag <tag.sig 2>err &&
+ if test -z "$no_strict"
then
- test_must_fail git mktag --no-strict <tag.sig 2>message.no-strict &&
- grep '$2' message.no-strict
+ test_must_fail git mktag <tag.sig 2>err2 &&
+ test_cmp err err2
+ else
+ git mktag --no-strict <tag.sig
fi
- "
+ '
+
+ test_expect_success "setup: $subject" '
+ tag_ref=refs/tags/bad_tag &&
+
+ # Reset any leftover state from the last $subject
+ rm -rf bad-tag &&
+
+ git init --bare bad-tag &&
+ bad_tag=$(git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig)
+ '
+
+ test_expect_success "hash-object & fsck unreachable: $subject" '
+ if test -n "$fsck_obj_ok"
+ then
+ git -C bad-tag fsck
+ else
+ test_must_fail git -C bad-tag fsck
+ fi
+ '
+
+ test_expect_success "update-ref & fsck reachable: $subject" '
+ # Make sure the earlier test created it for us
+ git rev-parse "$bad_tag" &&
+
+ # The update-ref of the bad content will fail, do it
+ # anyway to see if it segfaults
+ test_might_fail git -C bad-tag update-ref "$tag_ref" "$bad_tag" &&
+
+ # Manually create the broken, we cannot do it with
+ # update-ref
+ echo "$bad_tag" >"bad-tag/$tag_ref" &&
+
+ # Unlike fsck-ing unreachable content above, this
+ # will always fail.
+ test_must_fail git -C bad-tag fsck
+ '
+
+ test_expect_success "for-each-ref: $subject" '
+ # Make sure the earlier test created it for us
+ git rev-parse "$bad_tag" &&
+
+ echo "$bad_tag" >"bad-tag/$tag_ref" &&
+
+ printf "%s tag\t%s\n" "$bad_tag" "$tag_ref" >expected &&
+ git -C bad-tag for-each-ref "$tag_ref" >actual &&
+ test_cmp expected actual &&
+
+ test_must_fail git -C bad-tag for-each-ref --format="%(*objectname)"
+ '
+
+ test_expect_success "fast-export & fast-import: $subject" '
+ # Make sure the earlier test created it for us
+ git rev-parse "$bad_tag" &&
+
+ test_must_fail git -C bad-tag fast-export --all &&
+ test_must_fail git -C bad-tag fast-export "$bad_tag"
+ '
}
test_expect_mktag_success() {
@@ -167,7 +245,8 @@ tagger . <> 0 +0000
EOF
check_verify_failure 'verify object (hash/type) check -- correct type, nonexisting object' \
- '^fatal: could not read tagged object'
+ '^fatal: could not read tagged object' \
+ --fsck-obj-ok
cat >tag.sig <<EOF
object $head
@@ -200,7 +279,8 @@ tagger . <> 0 +0000
EOF
check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
- '^fatal: object.*tagged as.*tree.*but is.*commit'
+ '^fatal: object.*tagged as.*tree.*but is.*commit' \
+ --fsck-obj-ok
############################################################
# 9.5. verify object (hash/type) check -- replacement
@@ -229,7 +309,8 @@ tagger . <> 0 +0000
EOF
check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
- '^fatal: object.*tagged as.*tree.*but is.*blob'
+ '^fatal: object.*tagged as.*tree.*but is.*blob' \
+ --fsck-obj-ok
############################################################
# 10. verify tag-name check
@@ -243,7 +324,9 @@ tagger . <> 0 +0000
EOF
check_verify_failure 'verify tag-name check' \
- '^error:.* badTagName:' '--no-strict'
+ '^error:.* badTagName:' \
+ --no-strict \
+ --fsck-obj-ok
############################################################
# 11. tagger line label check #1
@@ -257,7 +340,9 @@ This is filler
EOF
check_verify_failure '"tagger" line label check #1' \
- '^error:.* missingTaggerEntry:' '--no-strict'
+ '^error:.* missingTaggerEntry:' \
+ --no-strict \
+ --fsck-obj-ok
############################################################
# 12. tagger line label check #2
@@ -272,7 +357,9 @@ This is filler
EOF
check_verify_failure '"tagger" line label check #2' \
- '^error:.* missingTaggerEntry:' '--no-strict'
+ '^error:.* missingTaggerEntry:' \
+ --no-strict \
+ --fsck-obj-ok
############################################################
# 13. allow missing tag author name like fsck
@@ -301,7 +388,9 @@ tagger T A Gger <
EOF
check_verify_failure 'disallow malformed tagger' \
- '^error:.* badEmail:' '--no-strict'
+ '^error:.* badEmail:' \
+ --no-strict \
+ --fsck-obj-ok
############################################################
# 15. allow empty tag email
@@ -425,7 +514,9 @@ this line should not be here
EOF
check_verify_failure 'detect invalid header entry' \
- '^error:.* extraHeaderEntry:' '--no-strict'
+ '^error:.* extraHeaderEntry:' \
+ --no-strict \
+ --fsck-obj-ok
test_expect_success 'invalid header entry config & fsck' '
test_must_fail git mktag <tag.sig &&