git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/4] builtin-fast-export.c: turn error into warning
  2009-03-22 21:50 [PATCH 1/4] test-suite: adding a test for fast-export with tag variants Erik Faye-Lund
@ 2009-03-22 21:50 ` Erik Faye-Lund
  0 siblings, 0 replies; 6+ messages in thread
From: Erik Faye-Lund @ 2009-03-22 21:50 UTC (permalink / raw)
  To: git; +Cc: gitster, Erik Faye-Lund

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 <kusmabite@gmail.com>
---
 builtin-fast-export.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index fdf4ae9..02bad1f 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 */
-- 
1.6.2.1.226.gcb2dd

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] builtin-fast-export.c: turn error into warning
  2009-03-23 12:53 [PATCH 1/4] test-suite: adding a test for fast-export with tag variants Erik Faye-Lund
@ 2009-03-23 12:53 ` Erik Faye-Lund
  0 siblings, 0 replies; 6+ messages in thread
From: Erik Faye-Lund @ 2009-03-23 12:53 UTC (permalink / raw)
  To: git; +Cc: gitster, Erik Faye-Lund

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 <kusmabite@gmail.com>
---
 builtin-fast-export.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index fdf4ae9..02bad1f 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 */
-- 
1.6.2.1.225.g9a4a0.dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/4] test-suite: adding a test for fast-export with tag variants
@ 2009-03-30  9:08 Erik Faye-Lund
  2009-03-30  9:08 ` [PATCH 2/4] builtin-fast-export.c: turn error into warning Erik Faye-Lund
  0 siblings, 1 reply; 6+ messages in thread
From: Erik Faye-Lund @ 2009-03-30  9:08 UTC (permalink / raw)
  To: git; +Cc: gitster, Erik Faye-Lund

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
 t/t9301-fast-export.sh |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh
index b860626..763dde5 100755
--- a/t/t9301-fast-export.sh
+++ b/t/t9301-fast-export.sh
@@ -262,4 +262,21 @@ 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
+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
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] builtin-fast-export.c: turn error into warning
  2009-03-30  9:08 [PATCH 1/4] test-suite: adding a test for fast-export with tag variants Erik Faye-Lund
@ 2009-03-30  9:08 ` Erik Faye-Lund
  2009-03-30  9:08   ` [PATCH 3/4] builtin-fast-export.c: fix crash on tagged trees Erik Faye-Lund
  0 siblings, 1 reply; 6+ messages in thread
From: Erik Faye-Lund @ 2009-03-30  9:08 UTC (permalink / raw)
  To: git; +Cc: gitster, Erik Faye-Lund

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 <kusmabite@gmail.com>
---
 builtin-fast-export.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 34a419c..027c4aa 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -379,8 +379,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 */
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] builtin-fast-export.c: fix crash on tagged trees
  2009-03-30  9:08 ` [PATCH 2/4] builtin-fast-export.c: turn error into warning Erik Faye-Lund
@ 2009-03-30  9:08   ` Erik Faye-Lund
  2009-03-30  9:08     ` [PATCH 4/4] builtin-fast-export.c: handle nested tags Erik Faye-Lund
  0 siblings, 1 reply; 6+ messages in thread
From: Erik Faye-Lund @ 2009-03-30  9:08 UTC (permalink / raw)
  To: git; +Cc: gitster, 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 <kusmabite@gmail.com>
---
 builtin-fast-export.c  |    4 ++++
 t/t9301-fast-export.sh |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 027c4aa..2070288 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -376,6 +376,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 763dde5..b587feb 100755
--- a/t/t9301-fast-export.sh
+++ b/t/t9301-fast-export.sh
@@ -274,8 +274,8 @@ 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_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'
 
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] builtin-fast-export.c: handle nested tags
  2009-03-30  9:08   ` [PATCH 3/4] builtin-fast-export.c: fix crash on tagged trees Erik Faye-Lund
@ 2009-03-30  9:08     ` Erik Faye-Lund
  0 siblings, 0 replies; 6+ messages in thread
From: Erik Faye-Lund @ 2009-03-30  9:08 UTC (permalink / raw)
  To: git; +Cc: gitster, Erik Faye-Lund

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.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
 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 2070288..b23a502 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -363,7 +363,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;
 			}
@@ -376,7 +379,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 b587feb..495c051 100755
--- a/t/t9301-fast-export.sh
+++ b/t/t9301-fast-export.sh
@@ -276,7 +276,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
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-03-30  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-30  9:08 [PATCH 1/4] test-suite: adding a test for fast-export with tag variants Erik Faye-Lund
2009-03-30  9:08 ` [PATCH 2/4] builtin-fast-export.c: turn error into warning Erik Faye-Lund
2009-03-30  9:08   ` [PATCH 3/4] builtin-fast-export.c: fix crash on tagged trees Erik Faye-Lund
2009-03-30  9:08     ` [PATCH 4/4] builtin-fast-export.c: handle nested tags Erik Faye-Lund
  -- strict thread matches above, loose matches on Subject: below --
2009-03-23 12:53 [PATCH 1/4] test-suite: adding a test for fast-export with tag variants Erik Faye-Lund
2009-03-23 12:53 ` [PATCH 2/4] builtin-fast-export.c: turn error into warning Erik Faye-Lund
2009-03-22 21:50 [PATCH 1/4] test-suite: adding a test for fast-export with tag variants Erik Faye-Lund
2009-03-22 21:50 ` [PATCH 2/4] builtin-fast-export.c: turn error into warning Erik Faye-Lund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).