2006-07-29 21:15:47 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2008-09-03 12:59:27 +04:00
|
|
|
test_description='git mktag: tag object verify test'
|
2006-07-29 21:15:47 +04: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 20:28:18 +03:00
|
|
|
subject=$1 &&
|
|
|
|
message=$2 &&
|
|
|
|
shift 2 &&
|
|
|
|
|
2021-06-17 13:41:59 +03:00
|
|
|
no_strict= &&
|
|
|
|
fsck_obj_ok= &&
|
2021-06-14 20:28:18 +03:00
|
|
|
no_strict= &&
|
|
|
|
while test $# != 0
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--no-strict)
|
|
|
|
no_strict=yes
|
|
|
|
;;
|
2021-06-17 13:41:59 +03:00
|
|
|
--fsck-obj-ok)
|
|
|
|
fsck_obj_ok=yes
|
|
|
|
;;
|
2021-06-14 20:28:18 +03: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 14:47:27 +03:00
|
|
|
then
|
2021-06-14 20:28:18 +03:00
|
|
|
test_must_fail git mktag <tag.sig 2>err2 &&
|
|
|
|
test_cmp err err2
|
2021-06-14 20:28:19 +03:00
|
|
|
else
|
|
|
|
git mktag --no-strict <tag.sig
|
2021-01-06 14:47:27 +03:00
|
|
|
fi
|
2021-06-14 20:28:18 +03:00
|
|
|
'
|
2021-06-17 13:41:59 +03:00
|
|
|
|
|
|
|
test_expect_success "setup: $subject" '
|
2021-06-17 13:42:00 +03:00
|
|
|
tag_ref=refs/tags/bad_tag &&
|
|
|
|
|
2021-06-17 13:41:59 +03:00
|
|
|
# Reset any leftover state from the last $subject
|
|
|
|
rm -rf bad-tag &&
|
|
|
|
|
|
|
|
git init --bare bad-tag &&
|
2021-06-17 13:42:00 +03:00
|
|
|
bad_tag=$(git -C bad-tag hash-object -t tag -w --stdin --literally <tag.sig)
|
2021-06-17 13:41:59 +03: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 13:42:00 +03: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 16:38:17 +03: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 13:42:00 +03:00
|
|
|
|
|
|
|
# Unlike fsck-ing unreachable content above, this
|
|
|
|
# will always fail.
|
|
|
|
test_must_fail git -C bad-tag fsck
|
|
|
|
'
|
2021-06-17 13:42:01 +03: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 16:38:17 +03: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 13:42:01 +03: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 13:42:02 +03: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 21:15:47 +04:00
|
|
|
}
|
|
|
|
|
2021-01-05 22:42:40 +03: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 21:15:47 +04:00
|
|
|
###########################################################
|
|
|
|
# first create a commit, so we have a valid object/type
|
|
|
|
# for the tag.
|
2010-03-20 11:29:11 +03:00
|
|
|
test_expect_success 'setup' '
|
2021-01-05 22:42:34 +03:00
|
|
|
test_commit A &&
|
2021-01-05 22:42:42 +03: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 11:29:11 +03:00
|
|
|
'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
2021-01-05 22:42:50 +03: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 21:15:47 +04:00
|
|
|
############################################################
|
|
|
|
# 1. length check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
too short for a tag
|
|
|
|
EOF
|
|
|
|
|
2008-01-05 09:45:08 +03:00
|
|
|
check_verify_failure 'Tag object length check' \
|
2021-01-06 14:47:27 +03:00
|
|
|
'^error:.* missingObject:' 'strict'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 2. object line label check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2021-01-05 22:42:35 +03:00
|
|
|
xxxxxx $head
|
2006-07-29 21:15:47 +04:00
|
|
|
type tag
|
|
|
|
tag mytag
|
2008-03-27 19:16:04 +03:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 21:15:47 +04: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 22:42:46 +03:00
|
|
|
check_verify_failure '"object" line label check' '^error:.* missingObject:'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
2021-01-05 22:42:35 +03:00
|
|
|
# 3. object line hash check
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2021-01-05 22:42:35 +03:00
|
|
|
object $(echo $head | tr 0-9a-f z)
|
2006-07-29 21:15:47 +04:00
|
|
|
type tag
|
|
|
|
tag mytag
|
2008-03-27 19:16:04 +03:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 21:15:47 +04: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 22:42:46 +03:00
|
|
|
check_verify_failure '"object" line check' '^error:.* badObjectSha1:'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 4. type line label check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 22:16:42 +03:00
|
|
|
object $head
|
2006-07-29 21:15:47 +04:00
|
|
|
xxxx tag
|
|
|
|
tag mytag
|
2008-03-27 19:16:04 +03:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 21:15:47 +04: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 22:42:46 +03:00
|
|
|
check_verify_failure '"type" line label check' '^error:.* missingTypeEntry:'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 5. type line eol check
|
|
|
|
|
2019-08-18 22:16:42 +03:00
|
|
|
echo "object $head" >tag.sig
|
2007-01-16 04:31:29 +03:00
|
|
|
printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
|
2006-07-29 21:15:47 +04: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 22:42:46 +03:00
|
|
|
check_verify_failure '"type" line eol check' '^error:.* unterminatedHeader:'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 6. tag line label check #1
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 22:16:42 +03:00
|
|
|
object $head
|
2006-07-29 21:15:47 +04:00
|
|
|
type tag
|
|
|
|
xxx mytag
|
2008-03-27 19:16:04 +03:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 21:15:47 +04:00
|
|
|
EOF
|
|
|
|
|
2008-01-05 09:45:08 +03: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 22:42:46 +03:00
|
|
|
'^error:.* missingTagEntry:'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 7. tag line label check #2
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 22:16:42 +03:00
|
|
|
object $head
|
2006-07-29 21:15:47 +04:00
|
|
|
type taggggggggggggggggggggggggggggggg
|
|
|
|
tag
|
|
|
|
EOF
|
|
|
|
|
2008-01-05 09:45:08 +03: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 22:42:46 +03:00
|
|
|
'^error:.* badType:'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 8. type line type-name length check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 22:16:42 +03:00
|
|
|
object $head
|
2006-07-29 21:15:47 +04:00
|
|
|
type taggggggggggggggggggggggggggggggg
|
|
|
|
tag mytag
|
|
|
|
EOF
|
|
|
|
|
2008-01-05 09:45:08 +03: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 22:42:46 +03:00
|
|
|
'^error:.* badType:'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
2021-01-05 22:42:41 +03:00
|
|
|
# 9. verify object (hash/type) check
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
2019-08-18 22:16:42 +03:00
|
|
|
object $(test_oid deadbeef)
|
2021-01-05 22:42:41 +03:00
|
|
|
type tag
|
|
|
|
tag mytag
|
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
check_verify_failure 'verify object (hash/type) check -- correct type, nonexisting object' \
|
2021-06-17 13:41:59 +03:00
|
|
|
'^fatal: could not read tagged object' \
|
|
|
|
--fsck-obj-ok
|
2021-01-05 22:42:41 +03:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
2006-07-29 21:15:47 +04:00
|
|
|
type tagggg
|
|
|
|
tag mytag
|
2008-03-27 19:16:04 +03:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 21:15:47 +04:00
|
|
|
EOF
|
|
|
|
|
2021-01-05 22:42:41 +03: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 22:42:46 +03:00
|
|
|
'^error:.* badType:'
|
2021-01-05 22:42:41 +03: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 22:42:46 +03:00
|
|
|
'^error:.* badType:'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
2021-01-05 22:42:41 +03:00
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type tree
|
|
|
|
tag mytag
|
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 22:42:42 +03:00
|
|
|
check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
|
2021-06-17 13:41:59 +03:00
|
|
|
'^fatal: object.*tagged as.*tree.*but is.*commit' \
|
|
|
|
--fsck-obj-ok
|
2021-01-05 22:42:42 +03: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 22:42:41 +03:00
|
|
|
check_verify_failure 'verify object (hash/type) check -- mismatched type, valid object' \
|
2021-06-17 13:41:59 +03:00
|
|
|
'^fatal: object.*tagged as.*tree.*but is.*blob' \
|
|
|
|
--fsck-obj-ok
|
2021-01-05 22:42:41 +03:00
|
|
|
|
2006-07-29 21:15:47 +04:00
|
|
|
############################################################
|
|
|
|
# 10. verify tag-name check
|
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag my tag
|
2008-03-27 19:16:04 +03:00
|
|
|
tagger . <> 0 +0000
|
|
|
|
|
2006-07-29 21:15:47 +04:00
|
|
|
EOF
|
|
|
|
|
2008-01-05 09:45:08 +03:00
|
|
|
check_verify_failure 'verify tag-name check' \
|
2021-06-14 20:28:18 +03:00
|
|
|
'^error:.* badTagName:' \
|
2021-06-17 13:41:59 +03:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
2007-02-04 07:49:16 +03:00
|
|
|
# 11. tagger line label check #1
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
This is filler
|
2006-07-29 21:15:47 +04:00
|
|
|
EOF
|
|
|
|
|
2008-01-05 09:45:08 +03:00
|
|
|
check_verify_failure '"tagger" line label check #1' \
|
2021-06-14 20:28:18 +03:00
|
|
|
'^error:.* missingTaggerEntry:' \
|
2021-06-17 13:41:59 +03:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
############################################################
|
2007-02-04 07:49:16 +03:00
|
|
|
# 12. tagger line label check #2
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
This is filler
|
2006-07-29 21:15:47 +04:00
|
|
|
EOF
|
|
|
|
|
2008-01-05 09:45:08 +03:00
|
|
|
check_verify_failure '"tagger" line label check #2' \
|
2021-06-14 20:28:18 +03:00
|
|
|
'^error:.* missingTaggerEntry:' \
|
2021-06-17 13:41:59 +03:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2006-07-29 21:15:47 +04: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 22:42:46 +03:00
|
|
|
# 13. allow missing tag author name like fsck
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
2008-03-27 19:16:04 +03: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 22:42:46 +03:00
|
|
|
test_expect_mktag_success 'allow missing tag author name'
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
############################################################
|
2008-04-01 03:25:23 +04:00
|
|
|
# 14. disallow missing tag author name
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <
|
|
|
|
> 0 +0000
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2008-04-01 03:25:23 +04:00
|
|
|
check_verify_failure 'disallow malformed tagger' \
|
2021-06-14 20:28:18 +03:00
|
|
|
'^error:.* badEmail:' \
|
2021-06-17 13:41:59 +03:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2008-03-27 19:16:04 +03: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 22:42:40 +03:00
|
|
|
test_expect_mktag_success 'allow empty tag email'
|
2008-03-27 19:16:04 +03: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 22:42:46 +03:00
|
|
|
# 16. allow spaces in tag email like fsck
|
2008-04-01 03:25:23 +04: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 22:42:46 +03:00
|
|
|
test_expect_mktag_success 'allow spaces in tag email like fsck'
|
2008-04-01 03:25:23 +04:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 17. disallow missing tag timestamp
|
2008-03-27 19:16:04 +03:00
|
|
|
|
2008-06-14 11:26:37 +04:00
|
|
|
tr '_' ' ' >tag.sig <<EOF
|
2008-03-27 19:16:04 +03:00
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
2008-06-14 11:26:37 +04:00
|
|
|
tagger T A Gger <tagger@example.com>__
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2008-04-01 03:25:23 +04: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 22:42:46 +03:00
|
|
|
'^error:.* badDate:'
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
############################################################
|
2008-04-01 03:25:23 +04:00
|
|
|
# 18. detect invalid tag timestamp1
|
2008-03-27 19:16:04 +03: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-04-01 03:25:23 +04: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 22:42:46 +03:00
|
|
|
'^error:.* badDate:'
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
############################################################
|
2008-04-01 03:25:23 +04: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 22:42:46 +03:00
|
|
|
'^error:.* badDate:'
|
2008-04-01 03:25:23 +04:00
|
|
|
|
|
|
|
############################################################
|
|
|
|
# 20. detect invalid tag timezone1
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 GMT
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2008-04-01 03:25:23 +04: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 22:42:46 +03:00
|
|
|
'^error:.* badTimezone:'
|
2008-04-01 03:25:23 +04: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 22:42:46 +03:00
|
|
|
'^error:.* badTimezone:'
|
2008-04-01 03:25:23 +04: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 22:42:46 +03:00
|
|
|
# 22. allow invalid tag timezone3 (the maximum is -1200/+1400)
|
2008-04-01 03:25:23 +04: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 22:42:46 +03:00
|
|
|
test_expect_mktag_success 'allow invalid tag timezone'
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
############################################################
|
2008-04-01 03:25:23 +04:00
|
|
|
# 23. detect invalid header entry
|
2008-03-27 19:16:04 +03: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 20:28:18 +03:00
|
|
|
'^error:.* extraHeaderEntry:' \
|
2021-06-17 13:41:59 +03:00
|
|
|
--no-strict \
|
|
|
|
--fsck-obj-ok
|
2008-03-27 19:16:04 +03:00
|
|
|
|
2021-01-05 22:42:48 +03:00
|
|
|
test_expect_success 'invalid header entry config & fsck' '
|
|
|
|
test_must_fail git mktag <tag.sig &&
|
2021-01-06 14:47:27 +03:00
|
|
|
git mktag --no-strict <tag.sig &&
|
|
|
|
|
2021-01-05 22:42:48 +03:00
|
|
|
test_must_fail git -c fsck.extraHeaderEntry=error mktag <tag.sig &&
|
2021-01-06 14:47:27 +03:00
|
|
|
test_must_fail git -c fsck.extraHeaderEntry=error mktag --no-strict <tag.sig &&
|
|
|
|
|
2021-01-05 22:42:48 +03:00
|
|
|
test_must_fail git -c fsck.extraHeaderEntry=warn mktag <tag.sig &&
|
2021-01-06 14:47:27 +03:00
|
|
|
git -c fsck.extraHeaderEntry=warn mktag --no-strict <tag.sig &&
|
|
|
|
|
2021-01-05 22:42:48 +03:00
|
|
|
git -c fsck.extraHeaderEntry=ignore mktag <tag.sig &&
|
2021-01-06 14:47:27 +03:00
|
|
|
git -c fsck.extraHeaderEntry=ignore mktag --no-strict <tag.sig &&
|
|
|
|
|
2021-01-05 22:42:48 +03:00
|
|
|
git fsck &&
|
2021-02-11 04:53:50 +03:00
|
|
|
git -c fsck.extraHeaderEntry=warn fsck 2>err &&
|
2021-01-05 22:42:48 +03:00
|
|
|
grep "warning .*extraHeaderEntry:" err &&
|
2021-02-11 04:53:50 +03:00
|
|
|
test_must_fail git -c fsck.extraHeaderEntry=error 2>err fsck &&
|
2021-01-05 22:42:48 +03:00
|
|
|
grep "error .* extraHeaderEntry:" err
|
|
|
|
'
|
|
|
|
|
2021-01-05 22:42:39 +03: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 22:42:40 +03:00
|
|
|
test_expect_mktag_success 'allow extra newlines at start of body'
|
2021-01-05 22:42:39 +03:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 22:42:49 +03:00
|
|
|
test_expect_mktag_success 'allow a blank line before an empty body (1)'
|
2021-01-05 22:42:39 +03:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
|
|
|
EOF
|
|
|
|
|
2021-01-05 22:42:49 +03:00
|
|
|
test_expect_mktag_success 'allow no blank line before an empty body (2)'
|
2021-01-05 22:42:39 +03:00
|
|
|
|
2008-03-27 19:16:04 +03:00
|
|
|
############################################################
|
2008-04-01 03:25:23 +04:00
|
|
|
# 24. create valid tag
|
2008-03-27 19:16:04 +03:00
|
|
|
|
|
|
|
cat >tag.sig <<EOF
|
|
|
|
object $head
|
|
|
|
type commit
|
|
|
|
tag mytag
|
|
|
|
tagger T A Gger <tagger@example.com> 1206478233 -0500
|
2006-07-29 21:15:47 +04:00
|
|
|
EOF
|
|
|
|
|
2021-01-05 22:42:40 +03:00
|
|
|
test_expect_mktag_success 'create valid tag object'
|
2006-07-29 21:15:47 +04:00
|
|
|
|
|
|
|
test_done
|