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