test-suite: adding a test for fast-export with tag variants
PATCH 1/4 test-suite: adding a test for fast-export with tag variants
--- t/t9302-fast-export-tags.sh | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 t/t9302-fast-export-tags.sh
t/t9302-fast-export-tags.sh new file +25 -0
@@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (c) 2009 Erik Faye-Lund +# + +test_description='git fast-export tag variants' +. ./test-lib.sh + +test_expect_success 'setup' ' + touch dummy && + git add dummy && + git commit -m "initial commit" && + HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` && + git tag tree_tag -m "tagging a tree" $HEAD_TREE && + git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE && + git tag tag-obj_tag -m "tagging a tag" tree_tag-obj && + git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj +' + +test_expect_success 'tree_tag' 'git fast-export tree_tag' +test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' +test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' +test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' + +test_done
Signature · 1 line
1.6.2.1.226.gcb2dd
PATCH 2/4 builtin-fast-export.c: turn error into warning
fast-import doesn't have a syntax to support tree-objects (and some other object-types), so fast-export shouldn't handle them. However, aborting the operation is a bit drastic. This patch turns the error into a warning instead.
--- builtin-fast-export.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
builtin-fast-export.c +4 -2
@@ -378,8 +378,10 @@ static void get_tags_and_duplicates(struct object_array *pending, }break ;default : -die ("Unexpected object of type %s" , -typename (e->item->type)); +warning ("%s: Unexpected object of type %s, skipping." , + e->name, +typename (e->item->type)); +continue ; }if (commit->util)/* more than one name for the same object */
Signature · 1 line
1.6.2.1.226.gcb2dd
PATCH 3/4 builtin-fast-export.c: fix crash on tagged trees
If a tag object points to a tree (or another unhandled type), the commit- pointer is left uninitialized and later dereferenced. This patch adds a default case to the switch that issues a warning and skips the object.
--- builtin-fast-export.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
builtin-fast-export.c +4 -0
@@ -375,6 +375,10 @@ static void get_tags_and_duplicates(struct object_array *pending,case OBJ_BLOB :handle_object (tag->object.sha1);continue ; +default :/* OBJ_TAG (nested tags) is already handled */ +warning ("Tag points to object of unexpected type %s, skipping." , +typename (tag->object.type)); +continue ; }break ;default :
Signature · 1 line
1.6.2.1.226.gcb2dd
PATCH 4/4 builtin-fast-export.c: handle nested tags
When tags that points to tags are passed to fast-export, an error saying "Tag [TAGNAME] points nowhere?". This fix calls parse_object() on the object before referencing it's tag, to ensure the tag-info is fully initialized. In addition, it inserts a comment to point out where nested tags are handled. This is consistent with the comment for signed tags.
--- builtin-fast-export.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
builtin-fast-export.c +3 -0
@@ -362,7 +362,10 @@ static void get_tags_and_duplicates(struct object_array *pending,break ;case OBJ_TAG : tag = (struct tag *)e->item; + +/* handle nested tags */ while (tag && tag->object.type ==OBJ_TAG ) { +parse_object (tag->object.sha1);string_list_append (full_name, extra_refs)->util = tag; tag = (struct tag *)tag->tagged; }
Signature · 1 line
1.6.2.1.226.gcb2dd
Re: [PATCH 3/4] builtin-fast-export.c: fix crash on tagged trees
In reply to Erik Faye-LundQuoted 14 lines · Erik Faye-Lund
If a tag object points to a tree (or another unhandled type), the commit- pointer is left uninitialized and later dereferenced. This patch adds a default case to the switch that issues a warning and skips the object.
Signed-off-by Erik Faye-Lund <[email protected]>--- builtin-fast-export.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)builtin-fast-export.c +0
-0
builtin-fast-export.c static void get_tags_and_duplicates(struct object_array *pending, · line 378
Quoted 4 lines
builtin-fast-export.c +1
-0@@ -375,6 +375,10 @@ static void get_tags_and_duplicates(struct object_array *pending,case OBJ_BLOB :handle_object (tag->object.sha1);continue ; +default :/* OBJ_TAG (nested tags) is already handled */
The comment is good but only if you make this the last patch that comes after the one that actually fixes the tag-to-tag (currently 4/4), no?
Quoted 8 lines
builtin-fast-export.c +3
-0+warning ("Tag points to object of unexpected type %s, skipping." , +typename (tag->object.type)); +continue ; }break ;default :Signature · 1 line
1.6.2.1.226.gcb2dd
Re: [PATCH 3/4] builtin-fast-export.c: fix crash on tagged trees
Quoted 2 lines
The comment is good but only if you make this the last patch that comes after the one that actually fixes the tag-to-tag (currently 4/4), no?
Ah, good catch! I'll reorder the commits. The order of the last two patches isn't really important, so if it makes the comment more senseful, I'm all for it ;)
Signature · 3 lines
Erik "kusma" Faye-Lund [email protected] (+47) 986 59 656
t/t9302-fast-export-tags.sh
Quoted 8 lines · Erik Faye-Lund
Signed-off-by Erik Faye-Lund <[email protected]>--- t/t9302-fast-export-tags.sh | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 t/t9302-fast-export-tags.sht/t9302-fast-export-tags.sh new file +0
-0
Make it executable if you need to add a new script, but shouldn't these small tests be done as an addition to existing t9301, not as a brand new script?
Quoted 19 lines
index 0000000..2ecac32
t/t9302-fast-export-tags.sh new file +15
-0@@ -0,0 +1,25 @@ +#!/bin/sh +# +# Copyright (c) 2009 Erik Faye-Lund +# + +test_description='git fast-export tag variants' +. ./test-lib.sh + +test_expect_success 'setup' ' + touch dummy && + git add dummy && + git commit -m "initial commit" && + HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` && + git tag tree_tag -m "tagging a tree" $HEAD_TREE && + git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE &&
t/t9302-fast-export-tags.sh line 25
Quoted 10 lines
t/t9302-fast-export-tags.sh new file +10
-0+ git tag tag-obj_tag -m "tagging a tag" tree_tag-obj && + git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj +' + +test_expect_success 'tree_tag' 'git fast-export tree_tag' +test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' +test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' +test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' + +test_done
The purpose of the first patch that adds tests is to expose existing problems, and it is better to say test_expect_failure in them. Later patch to fix these issues will contain code change and also change to flip some of the expect_failure to expect_success, and that way we can see what issue is fixed with which patch more easily.
These tests seem to only care about fast-export not dying, but don't we also want to check if they produce correct results?
Quoted 6 lines · Junio C Hamano
t/t9302-fast-export-tags.sh
Quoted 2 lines
t/t9302-fast-export-tags.sh new file +0
-0Make it executable if you need to add a new script, but shouldn't these small tests be done as an addition to existing t9301, not as a brand new script?
Sure, will do. I just have to figure out how to make it executable in windows ;)
As this is my first test, I was wondering a bit about how much I could depend on the state of the repo, so I was a bit reluctant to add it to the same test. But I guess it's easier for everyone in the long term to put it into the same test, so I'll give it a go.
Quoted 4 lines
Quoted 4 lines
t/t9302-fast-export-tags.sh new file +4
-0+test_expect_success 'tree_tag' 'git fast-export tree_tag' +test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' +test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' +test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'
Quoted 8 lines
t/t9302-fast-export-tags.sh
Quoted 2 lines
t/t9302-fast-export-tags.sh new file +2
-0+ +test_doneThe purpose of the first patch that adds tests is to expose existing problems, and it is better to say
test_expect_failurein them. Later patch to fix these issues will contain code change and also change to flip some of theexpect_failuretoexpect_success, and that way we can see what issue is fixed with which patch more easily.
Sure, will do. I was a bit lazy, but updating it as we go will make stuff easier in the future.
Quoted 2 lines
These tests seem to only care about fast-export not dying, but don't we also want to check if they produce correct results?
Well, yeah. But I was working mainly on fixing a crash-bug here, and I don't think I know enough about the correct output of fast-export to pull this off. Perhaps tighting up the test is something someone else would care to do?
Signature · 3 lines
Erik "kusma" Faye-Lund [email protected] (+47) 986 59 656
Quoted 9 lines · Erik Faye-Lund
On Mon, Mar 23, 2009 at 1:39 AM, Junio C Hamano <[email protected]> wrote:
...Quoted 2 lines
These tests seem to only care about fast-export not dying, but don't we also want to check if they produce correct results?
Well, yeah. But I was working mainly on fixing a crash-bug here, and I don't think I know enough about the correct output of fast-export to pull this off. Perhaps tighting up the test is something someone else would care to do?
Surely; for a starter, saying something like this:
+# NEEDSWORK: not just check return status, but validate the output +test_expect_failure 'tree_tag' 'git fast-export tree_tag' +test_expect_failure 'tree_tag-obj' 'git fast-export tree_tag-obj' +test_expect_failure 'tag-obj_tag' 'git fast-export tag-obj_tag' +test_expect_failure 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'
would do, and will invite others to fill the gap when they have time.
Thanks.