From 4cedb78cb5eeb26d6dd47f866b51f061737616f2 Mon Sep 17 00:00:00 2001 From: Dmitry Ivankov Date: Thu, 11 Aug 2011 16:21:06 +0600 Subject: fast-import: add input format tests Documentation/git-fast-import.txt says that git-fast-import is strict about it's input format. But committer/author field parsing is a bit loose. Invalid values can be unnoticed and written out to the commit, either with format-conforming input or with non-format-conforming one. Add one passing and one failing test for empty/absent committer name with well-formed input. And a failed test with unnoticed ill-formed input. Reported-by: SASAKI Suguru Signed-off-by: Dmitry Ivankov Signed-off-by: Junio C Hamano --- t/t9300-fast-import.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 't/t9300-fast-import.sh') diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 2a53640c5b..a659dd408f 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -324,6 +324,105 @@ test_expect_success \ test `git rev-parse master` = `git rev-parse TEMP_TAG^`' rm -f .git/TEMP_TAG +git gc 2>/dev/null >/dev/null +git prune 2>/dev/null >/dev/null + +cat >input < $GIT_COMMITTER_DATE +data </dev/null >/dev/null +git prune 2>/dev/null >/dev/null + +cat >input < $GIT_COMMITTER_DATE +data </dev/null >/dev/null +git prune 2>/dev/null >/dev/null + +cat >input < $GIT_COMMITTER_DATE +data <input < $GIT_COMMITTER_DATE +data <input <> $GIT_COMMITTER_DATE +data <input <input < $GIT_COMMITTER_DATE +data < Date: Thu, 11 Aug 2011 16:21:07 +0600 Subject: fast-import: don't fail on omitted committer name fast-import format declares 'committer_name SP' to be optional in 'committer_name SP LT email GT'. But for a (commit) object SP is obligatory while zero length committer_name is ok. git-fsck checks that SP is present, so fast-import must prepend it if the name SP part is omitted. It doesn't do so and thus for "LT email GT" ident it writes a bad object. Name cannot contain LT or GT, ident always comes after SP in fast-import. So if ident starts with LT reuse the SP as if a valid 'SP LT email GT' ident was passed. This fixes a ident parsing bug for a well-formed fast-import input. Though the parsing is still loose and can accept a ill-formed input. Signed-off-by: Dmitry Ivankov Signed-off-by: Junio C Hamano --- t/t9300-fast-import.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t9300-fast-import.sh') diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index a659dd408f..09ef6ba1d9 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -352,7 +352,7 @@ data < Date: Thu, 11 Aug 2011 16:21:08 +0600 Subject: fast-import: check committer name more strictly The documentation declares following identity format: ( SP)? LT GT where name is any string without LF and LT characters. But fast-import just accepts any string up to first GT instead of checking the whole format, and moreover just writes it as is to the commit object. git-fsck checks for [^<\n]* <[^<>\n]*> format. Note that the space is mandatory. And the space quirk is already handled via extending the string to the left when needed. Modify fast-import input identity format to a slightly stricter one - deny LF, LT and GT in both and . And check for it. This is stricter then git-fsck as fsck accepts "Name> " currently, but soon fsck check will be adjusted likewise. Signed-off-by: Dmitry Ivankov Signed-off-by: Junio C Hamano --- t/t9300-fast-import.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 't/t9300-fast-import.sh') diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 09ef6ba1d9..18441f8fcb 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -370,7 +370,7 @@ data <