2006-07-29 17:15:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2008-09-03 08:59:27 +00:00
|
|
|
test_description='git mktag: tag object verify test'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
tests: mark tests as passing with SANITIZE=leak
When the "ab/various-leak-fixes" topic was merged in [1] only t6021
would fail if the tests were run in the
"GIT_TEST_PASSING_SANITIZE_LEAK=check" mode, i.e. to check whether we
marked all leak-free tests with "TEST_PASSES_SANITIZE_LEAK=true".
Since then we've had various tests starting to pass under
SANITIZE=leak. Let's mark those as passing, this is when they started
to pass, narrowed down with "git bisect":
- t5317-pack-objects-filter-objects.sh: In
faebba436e6 (list-objects-filter: plug pattern_list leak, 2022-12-01).
- t3210-pack-refs.sh, t5613-info-alternate.sh,
t7403-submodule-sync.sh: In 189e97bc4ba (diff: remove parseopts member
from struct diff_options, 2022-12-01).
- t1408-packed-refs.sh: In ab91f6b7c42 (Merge branch
'rs/diff-parseopts', 2022-12-19).
- t0023-crlf-am.sh, t4152-am-subjects.sh, t4254-am-corrupt.sh,
t4256-am-format-flowed.sh, t4257-am-interactive.sh,
t5403-post-checkout-hook.sh: In a658e881c13 (am: don't pass strvec to
apply_parse_options(), 2022-12-13)
- t1301-shared-repo.sh, t1302-repo-version.sh: In b07a819c05f (reflog:
clear leftovers in reflog_expiry_cleanup(), 2022-12-13).
- t1304-default-acl.sh, t1410-reflog.sh,
t5330-no-lazy-fetch-with-commit-graph.sh, t5502-quickfetch.sh,
t5604-clone-reference.sh, t6014-rev-list-all.sh,
t7701-repack-unpack-unreachable.sh: In b0c61be3209 (Merge branch
'rs/reflog-expiry-cleanup', 2022-12-26)
- t3800-mktag.sh, t5302-pack-index.sh, t5306-pack-nobase.sh,
t5573-pull-verify-signatures.sh, t7612-merge-verify-signatures.sh: In
69bbbe484ba (hash-object: use fsck for object checks, 2023-01-18).
- t1451-fsck-buffer.sh: In 8e4309038f0 (fsck: do not assume
NUL-termination of buffers, 2023-01-19).
- t6501-freshen-objects.sh: In abf2bb895b4 (Merge branch
'jk/hash-object-fsck', 2023-01-30)
1. 9ea1378d046 (Merge branch 'ab/various-leak-fixes', 2022-12-14)
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-02-06 23:07:36 +00:00
|
|
|
TEST_PASSES_SANITIZE_LEAK=true
|
2006-07-29 17:15:47 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# check the tag.sig file, expecting verify_tag() to fail,
|
|
|
|
# and checking that the error message matches the pattern
|
|
|
|
# given in the expect.pat file.
|
|
|
|
|
|
|
|
check_verify_failure () {
|
2021-06-14 17:28:18 +00:00
|
|
|
subject=$1 &&
|
|
|
|
message=$2 &&
|
|
|
|
shift 2 &&
|
|
|
|
|
2021-06-17 10:41:59 +00:00
|
|
|
no_strict= &&
|
|
|
|
fsck_obj_ok= &&
|
2021-06-14 17:28:18 +00:00
|
|
|
no_strict= &&
|
|
|
|
while test $# != 0
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--no-strict)
|
|
|
|
no_strict=yes
|
|
|
|
;;
|
2021-06-17 10:41:59 +00:00
|
|
|
--fsck-obj-ok)
|
|
|
|
fsck_obj_ok=yes
|
|
|
|
;;
|
2021-06-14 17:28:18 +00:00
|
|
|
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"
|
2021-01-06 11:47:27 +00:00
|
|
|
then
|
2021-06-14 17:28:18 +00:00
|
|
|
test_must_fail git mktag <tag.sig 2>err2 &&
|
|
|
|
test_cmp err err2
|
2021-06-14 17:28:19 +00:00
|
|
|
else
|
|
|
|
git mktag --no-strict <tag.sig
|
2021-01-06 11:47:27 +00:00
|
|
|
fi
|
2021-06-14 17:28:18 +00:00
|
|
|
'
|
2021-06-17 10:41:59 +00:00
|
|
|
|
|
|
|
test_expect_success "setup: $subject" '
|
2021-06-17 10:42:00 +00:00
|
|
|
tag_ref=refs/tags/bad_tag &&
|
|
|
|
|
2021-06-17 10:41:59 +00:00
|
|
|
# Reset any leftover state from the last $subject
|
|
|
|
rm -rf bad-tag &&
|
|
|
|
|
|
|
|
git init --bare bad-tag &&
|
2021-06-17 10:42:00 +00:00
|
|
|
bad_tag=$(git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig)
|
2021-06-17 10:41:59 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
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
|
|
|
|
'
|
2021-06-17 10:42:00 +00:00
|
|
|
|
|
|
|
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
|
2021-12-07 13:38:17 +00:00
|
|
|
test-tool -C bad-tag ref-store main delete-refs 0 msg "$tag_ref" &&
|
|
|
|
test-tool -C bad-tag ref-store main update-ref msg "$tag_ref" $bad_tag $ZERO_OID REF_SKIP_OID_VERIFICATION &&
|
2021-06-17 10:42:00 +00:00
|
|
|
|
|
|
|
# Unlike fsck-ing unreachable content above, this
|
|
|
|
# will always fail.
|
|
|
|
test_must_fail git -C bad-tag fsck
|
|
|
|
'
|
2021-06-17 10:42:01 +00:00
|
|
|
|
|
|
|
test_expect_success "for-each-ref: $subject" '
|
|
|
|
# Make sure the earlier test created it for us
|
|
|
|
git rev-parse "$bad_tag" &&
|
|
|
|
|
2021-12-07 13:38:17 +00:00
|
|
|
test-tool -C bad-tag ref-store main delete-refs 0 msg "$tag_ref" &&
|
|
|
|
test-tool -C bad-tag ref-store main update-ref msg "$tag_ref" $bad_tag $ZERO_OID REF_SKIP_OID_VERIFICATION &&
|
2021-06-17 10:42:01 +00:00
|
|
|
|
|
|
|
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)"
|
|
|
|
'
|
2021-06-17 10:42:02 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
'
|
2006-07-29 17:15:47 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 19:42:40 +00:00
|
|
|
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
|
|
|
|
'
|
|
|
|
}
|
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
###########################################################
|
|
|
|
# first create a commit, so we have a valid object/type
|
|
|
|
# for the tag.
|
2010-03-20 08:29:11 +00:00
|
|
|
test_expect_success 'setup' '
|
2021-01-05 19:42:34 +00:00
|
|
|
test_commit A &&
|
2021-01-05 19:42:42 +00:00
|
|
|
test_commit B &&
|
|
|
|
head=$(git rev-parse --verify HEAD) &&
|
|
|
|
head_parent=$(git rev-parse --verify HEAD~) &&
|
|
|
|
tree=$(git rev-parse HEAD^{tree}) &&
|
|
|
|
blob=$(git rev-parse --verify HEAD:B.t)
|
2010-03-20 08:29:11 +00:00
|
|
|
'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
2021-01-05 19:42:50 +00:00
|
|
|
test_expect_success 'basic usage' '
|
|
|
|
cat >tag.sig <<-EOF &&
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
|
|
|
EOF
|
|
|
|
git mktag <tag.sig &&
|
|
|
|
git mktag --end-of-options <tag.sig &&
|
|
|
|
test_expect_code 129 git mktag --unknown-option
|
|
|
|
'
|
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
############################################################
|
|
|
|
# 1. length check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
too short for a tag
|
|
|
|
EOF
|
|
|
|
|
2008-01-05 06:45:08 +00:00
|
|
|
check_verify_failure 'Tag object length check' \
|
2021-01-06 11:47:27 +00:00
|
|
|
'^error:.* missingObject:' 'strict'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 2. object line label check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2021-01-05 19:42:35 +00:00
|
|
|
xxxxxx $head
|
2006-07-29 17:15:47 +00:00
|
|
|
type tag
|
|
|
|
tag mytag
|
2008-03-27 16:16:04 +00:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
check_verify_failure '"object" line label check' '^error:.* missingObject:'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
2021-01-05 19:42:35 +00:00
|
|
|
# 3. object line hash check
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2021-01-05 19:42:35 +00:00
|
|
|
object $(echo $head | tr 0-9a-f z)
|
2006-07-29 17:15:47 +00:00
|
|
|
type tag
|
|
|
|
tag mytag
|
2008-03-27 16:16:04 +00:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
check_verify_failure '"object" line check' '^error:.* badObjectSha1:'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 4. type line label check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 19:16:42 +00:00
|
|
|
object $head
|
2006-07-29 17:15:47 +00:00
|
|
|
xxxx tag
|
|
|
|
tag mytag
|
2008-03-27 16:16:04 +00:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
check_verify_failure '"type" line label check' '^error:.* missingTypeEntry:'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 5. type line eol check
|
|
|
|
|
2019-08-18 19:16:42 +00:00
|
|
|
echo "object $head" >tag.sig
|
2007-01-16 01:31:29 +00:00
|
|
|
printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
|
2006-07-29 17:15:47 +00:00
|
|
|
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
check_verify_failure '"type" line eol check' '^error:.* unterminatedHeader:'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 6. tag line label check #1
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 19:16:42 +00:00
|
|
|
object $head
|
2006-07-29 17:15:47 +00:00
|
|
|
type tag
|
|
|
|
xxx mytag
|
2008-03-27 16:16:04 +00:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
2008-01-05 06:45:08 +00:00
|
|
|
check_verify_failure '"tag" line label check #1' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* missingTagEntry:'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 7. tag line label check #2
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 19:16:42 +00:00
|
|
|
object $head
|
2006-07-29 17:15:47 +00:00
|
|
|
type taggggggggggggggggggggggggggggggg
|
|
|
|
tag
|
|
|
|
EOF
|
|
|
|
|
2008-01-05 06:45:08 +00:00
|
|
|
check_verify_failure '"tag" line label check #2' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badType:'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 8. type line type-name length check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 19:16:42 +00:00
|
|
|
object $head
|
2006-07-29 17:15:47 +00:00
|
|
|
type taggggggggggggggggggggggggggggggg
|
|
|
|
tag mytag
|
|
|
|
EOF
|
|
|
|
|
2008-01-05 06:45:08 +00:00
|
|
|
check_verify_failure '"type" line type-name length check' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badType:'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
2021-01-05 19:42:41 +00:00
|
|
|
# 9. verify object (hash/type) check
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 19:16:42 +00:00
|
|
|
object $(test_oid deadbeef)
|
2021-01-05 19:42:41 +00:00
|
|
|
type tag
|
|
|
|
tag mytag
|
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
check_verify_failure 'verify object (hash/type) check -- correct type, nonexisting object' \
|
2021-06-17 10:41:59 +00:00
|
|
|
'^fatal: could not read tagged object' \
|
|
|
|
--fsck-obj-ok
|
2021-01-05 19:42:41 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
2006-07-29 17:15:47 +00:00
|
|
|
type tagggg
|
|
|
|
tag mytag
|
2008-03-27 16:16:04 +00:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
2021-01-05 19:42:41 +00:00
|
|
|
check_verify_failure 'verify object (hash/type) check -- made-up type, valid object' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badType:'
|
2021-01-05 19:42:41 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $(test_oid deadbeef)
|
|
|
|
type tagggg
|
|
|
|
tag mytag
|
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
check_verify_failure 'verify object (hash/type) check -- made-up type, nonexisting object' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badType:'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
2021-01-05 19:42:41 +00:00
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type tree
|
|
|
|
tag mytag
|
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 19:42:42 +00:00
|
|
|
check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
|
2021-06-17 10:41:59 +00:00
|
|
|
'^fatal: object.*tagged as.*tree.*but is.*commit' \
|
|
|
|
--fsck-obj-ok
|
2021-01-05 19:42:42 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 9.5. verify object (hash/type) check -- replacement
|
|
|
|
|
|
|
|
test_expect_success 'setup replacement of commit -> commit and tree -> blob' '
|
|
|
|
git replace $head_parent $head &&
|
|
|
|
git replace -f $tree $blob
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head_parent
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_mktag_success 'tag to a commit replaced by another commit'
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $tree
|
|
|
|
type tree
|
|
|
|
tag mytag
|
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 19:42:41 +00:00
|
|
|
check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
|
2021-06-17 10:41:59 +00:00
|
|
|
'^fatal: object.*tagged as.*tree.*but is.*blob' \
|
|
|
|
--fsck-obj-ok
|
2021-01-05 19:42:41 +00:00
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
############################################################
|
|
|
|
# 10. verify tag-name check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag my tag
|
2008-03-27 16:16:04 +00:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
2008-01-05 06:45:08 +00:00
|
|
|
check_verify_failure 'verify tag-name check' \
|
2021-06-14 17:28:18 +00:00
|
|
|
'^error:.* badTagName:' \
|
2021-06-17 10:41:59 +00:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
2007-02-04 04:49:16 +00:00
|
|
|
# 11. tagger line label check #1
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
This is filler
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
2008-01-05 06:45:08 +00:00
|
|
|
check_verify_failure '"tagger" line label check #1' \
|
2021-06-14 17:28:18 +00:00
|
|
|
'^error:.* missingTaggerEntry:' \
|
2021-06-17 10:41:59 +00:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
2007-02-04 04:49:16 +00:00
|
|
|
# 12. tagger line label check #2
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
This is filler
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
2008-01-05 06:45:08 +00:00
|
|
|
check_verify_failure '"tagger" line label check #2' \
|
2021-06-14 17:28:18 +00:00
|
|
|
'^error:.* missingTaggerEntry:' \
|
2021-06-17 10:41:59 +00:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
############################################################
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
# 13. allow missing tag author name like fsck
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
2008-03-27 16:16:04 +00:00
|
|
|
tagger <> 0 +0000
|
|
|
|
|
|
|
|
This is filler
|
|
|
|
EOF
|
|
|
|
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
test_expect_mktag_success 'allow missing tag author name'
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
############################################################
|
2008-03-31 23:25:23 +00:00
|
|
|
# 14. disallow missing tag author name
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <
|
|
|
|
> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2008-03-31 23:25:23 +00:00
|
|
|
check_verify_failure 'disallow malformed tagger' \
|
2021-06-14 17:28:18 +00:00
|
|
|
'^error:.* badEmail:' \
|
2021-06-17 10:41:59 +00:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 15. allow empty tag email
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 19:42:40 +00:00
|
|
|
test_expect_mktag_success 'allow empty tag email'
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
############################################################
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
# 16. allow spaces in tag email like fsck
|
2008-03-31 23:25:23 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tag ger@example.com> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
test_expect_mktag_success 'allow spaces in tag email like fsck'
|
2008-03-31 23:25:23 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 17. disallow missing tag timestamp
|
2008-03-27 16:16:04 +00:00
|
|
|
|
2008-06-14 07:26:37 +00:00
|
|
|
tr '_' ' ' >tag.sig <<EOF
|
2008-03-27 16:16:04 +00:00
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
2008-06-14 07:26:37 +00:00
|
|
|
tagger T A Gger <tagger@example.com>__
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2008-03-31 23:25:23 +00:00
|
|
|
check_verify_failure 'disallow missing tag timestamp' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badDate:'
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
############################################################
|
2008-03-31 23:25:23 +00:00
|
|
|
# 18. detect invalid tag timestamp1
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2008-03-31 23:25:23 +00:00
|
|
|
check_verify_failure 'detect invalid tag timestamp1' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badDate:'
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
############################################################
|
2008-03-31 23:25:23 +00:00
|
|
|
# 19. detect invalid tag timestamp2
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 2008-03-31T12:20:15-0500
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
check_verify_failure 'detect invalid tag timestamp2' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badDate:'
|
2008-03-31 23:25:23 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 20. detect invalid tag timezone1
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 GMT
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2008-03-31 23:25:23 +00:00
|
|
|
check_verify_failure 'detect invalid tag timezone1' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badTimezone:'
|
2008-03-31 23:25:23 +00:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 21. detect invalid tag timezone2
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 + 30
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
check_verify_failure 'detect invalid tag timezone2' \
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
'^error:.* badTimezone:'
|
2008-03-31 23:25:23 +00:00
|
|
|
|
|
|
|
############################################################
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
# 22. allow invalid tag timezone3 (the maximum is -1200/+1400)
|
2008-03-31 23:25:23 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -1430
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
mktag: use fsck instead of custom verify_tag()
Change the validation logic in "mktag" to use fsck's fsck_tag()
instead of its own custom parser. Curiously the logic for both dates
back to the same commit[1]. Let's unify them so we're not maintaining
two sets functions to verify that a tag is OK.
The behavior of fsck_tag() and the old "mktag" code being removed here
is different in few aspects.
I think it makes sense to remove some of those checks, namely:
A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag
code disallowed values larger than 1400.
Yes there's currently no timezone with a greater offset[2], but
since we allow any number of non-offical timezones (e.g. +1234)
passing this through seems fine. Git also won't break in the
future if e.g. French Polynesia decides it needs to outdo the Line
Islands when it comes to timezone extravagance.
B. fsck allows missing author names such as "tagger <email>", mktag
wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but
not "tagger [1 space] <email>"). Now we allow all of these.
C. Like B, but "mktag" disallowed spaces in the <email> part, fsck
allows it.
In some ways fsck_tag() is stricter than "mktag" was, namely:
D. fsck disallows zero-padded dates, but mktag didn't care. So
e.g. the timestamp "0000000000 +0000" produces an error now. A
test in "t1006-cat-file.sh" relied on this, it's been changed to
use "hash-object" (without fsck) instead.
There was one check I deemed worth keeping by porting it over to
fsck_tag():
E. "mktag" did not allow any custom headers, and by extension (as an
empty commit is allowed) also forbade an extra stray trailing
newline after the headers it knew about.
Add a new check in the "ignore" category to fsck and use it. This
somewhat abuses the facility added in efaba7cc77f (fsck:
optionally ignore specific fsck issues completely, 2015-06-22).
This is somewhat of hack, but probably the least invasive change
we can make here. The fsck command will shuffle these categories
around, e.g. under --strict the "info" becomes a "warn" and "warn"
becomes "error". Existing users of fsck's (and others,
e.g. index-pack) --strict option rely on this.
So we need to put something into a category that'll be ignored by
all existing users of the API. Pretending that
fsck.extraHeaderEntry=error ("ignore" by default) was set serves
to do this for us.
1. ec4465adb38 (Add "tag" objects that can be used to sign other
objects., 2005-04-25)
2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05 19:42:46 +00:00
|
|
|
test_expect_mktag_success 'allow invalid tag timezone'
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
############################################################
|
2008-03-31 23:25:23 +00:00
|
|
|
# 23. detect invalid header entry
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
|
|
|
this line should not be here
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
check_verify_failure 'detect invalid header entry' \
|
2021-06-14 17:28:18 +00:00
|
|
|
'^error:.* extraHeaderEntry:' \
|
2021-06-17 10:41:59 +00:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2008-03-27 16:16:04 +00:00
|
|
|
|
2021-01-05 19:42:48 +00:00
|
|
|
test_expect_success 'invalid header entry config & fsck' '
|
|
|
|
test_must_fail git mktag <tag.sig &&
|
2021-01-06 11:47:27 +00:00
|
|
|
git mktag --no-strict <tag.sig &&
|
|
|
|
|
2021-01-05 19:42:48 +00:00
|
|
|
test_must_fail git -c fsck.extraHeaderEntry=error mktag <tag.sig &&
|
2021-01-06 11:47:27 +00:00
|
|
|
test_must_fail git -c fsck.extraHeaderEntry=error mktag --no-strict <tag.sig &&
|
|
|
|
|
2021-01-05 19:42:48 +00:00
|
|
|
test_must_fail git -c fsck.extraHeaderEntry=warn mktag <tag.sig &&
|
2021-01-06 11:47:27 +00:00
|
|
|
git -c fsck.extraHeaderEntry=warn mktag --no-strict <tag.sig &&
|
|
|
|
|
2021-01-05 19:42:48 +00:00
|
|
|
git -c fsck.extraHeaderEntry=ignore mktag <tag.sig &&
|
2021-01-06 11:47:27 +00:00
|
|
|
git -c fsck.extraHeaderEntry=ignore mktag --no-strict <tag.sig &&
|
|
|
|
|
2021-01-05 19:42:48 +00:00
|
|
|
git fsck &&
|
2021-02-11 01:53:50 +00:00
|
|
|
git -c fsck.extraHeaderEntry=warn fsck 2>err &&
|
2021-01-05 19:42:48 +00:00
|
|
|
grep "warning .*extraHeaderEntry:" err &&
|
2021-02-11 01:53:50 +00:00
|
|
|
test_must_fail git -c fsck.extraHeaderEntry=error 2>err fsck &&
|
2021-01-05 19:42:48 +00:00
|
|
|
grep "error .* extraHeaderEntry:" err
|
|
|
|
'
|
|
|
|
|
2021-01-05 19:42:39 +00:00
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
|
|
|
|
|
|
|
|
|
|
|
this line comes after an extra newline
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 19:42:40 +00:00
|
|
|
test_expect_mktag_success 'allow extra newlines at start of body'
|
2021-01-05 19:42:39 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 19:42:49 +00:00
|
|
|
test_expect_mktag_success 'allow a blank line before an empty body (1)'
|
2021-01-05 19:42:39 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 19:42:49 +00:00
|
|
|
test_expect_mktag_success 'allow no blank line before an empty body (2)'
|
2021-01-05 19:42:39 +00:00
|
|
|
|
2008-03-27 16:16:04 +00:00
|
|
|
############################################################
|
2008-03-31 23:25:23 +00:00
|
|
|
# 24. create valid tag
|
2008-03-27 16:16:04 +00:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
2006-07-29 17:15:47 +00:00
|
|
|
EOF
|
|
|
|
|
2021-01-05 19:42:40 +00:00
|
|
|
test_expect_mktag_success 'create valid tag object'
|
2006-07-29 17:15:47 +00:00
|
|
|
|
|
|
|
test_done
|