From 41a5c70f2caf5c22859574f0503afbdb3728a89c Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 23 Mar 2009 12:53:06 +0000 Subject: test-suite: adding a test for fast-export with tag variants Signed-off-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- t/t9301-fast-export.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh index 86c376088c..2e31f67465 100755 --- a/t/t9301-fast-export.sh +++ b/t/t9301-fast-export.sh @@ -259,4 +259,20 @@ test_expect_success 'cope with tagger-less tags' ' ' +test_expect_success 'set-up a few more tags for tag export tests' ' + git checkout -f master && + 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 +' + +# NEEDSWORK: not just check return status, but validate the output +# two tests commented out due to crash and thus unreliable return code +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' + test_done -- cgit v1.2.1 From 2d07f6d4b728d19d115b89123224268718f34efd Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 23 Mar 2009 12:53:07 +0000 Subject: 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. Signed-off-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- builtin-fast-export.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin-fast-export.c b/builtin-fast-export.c index fdf4ae9ebd..8a6cf5e649 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -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 */ -- cgit v1.2.1 From c0582c53bcf4e83bba70e1ad23abbad31f96ebc8 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 23 Mar 2009 12:53:08 +0000 Subject: 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. Signed-off-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- builtin-fast-export.c | 4 ++++ t/t9301-fast-export.sh | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 8a6cf5e649..1ec459f057 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -375,6 +375,10 @@ static void get_tags_and_duplicates(struct object_array *pending, case OBJ_BLOB: handle_object(tag->object.sha1); continue; + default: + warning("Tag points to object of unexpected type %s, skipping.", + typename(tag->object.type)); + continue; } break; default: diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh index 2e31f67465..b1f75ceea4 100755 --- a/t/t9301-fast-export.sh +++ b/t/t9301-fast-export.sh @@ -269,9 +269,8 @@ test_expect_success 'set-up a few more tags for tag export tests' ' ' # NEEDSWORK: not just check return status, but validate the output -# two tests commented out due to crash and thus unreliable return code -test_expect_failure 'tree_tag' 'git fast-export tree_tag' -test_expect_failure 'tree_tag-obj' 'git fast-export 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_failure 'tag-obj_tag' 'git fast-export tag-obj_tag' test_expect_failure 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' -- cgit v1.2.1 From 1982467d9229e3c92157f2a41363365dcb866e86 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 23 Mar 2009 12:53:09 +0000 Subject: builtin-fast-export.c: handle nested tags When tags that points to tags are passed to fast-export, an error is given, 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. Signed-off-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- builtin-fast-export.c | 5 ++++- t/t9301-fast-export.sh | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 1ec459f057..f171ee4a2b 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -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; } @@ -375,7 +378,7 @@ static void get_tags_and_duplicates(struct object_array *pending, case OBJ_BLOB: handle_object(tag->object.sha1); continue; - default: + default: /* OBJ_TAG (nested tags) is already handled */ warning("Tag points to object of unexpected type %s, skipping.", typename(tag->object.type)); continue; diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh index b1f75ceea4..4a87f36258 100755 --- a/t/t9301-fast-export.sh +++ b/t/t9301-fast-export.sh @@ -271,7 +271,7 @@ test_expect_success 'set-up a few more tags for tag export tests' ' # NEEDSWORK: not just check return status, but validate the output test_expect_success 'tree_tag' 'git fast-export tree_tag' test_expect_success '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' +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 -- cgit v1.2.1