@matheusbsbs / matheus-bagliano / commits / 02c48cd69b
Fork 0

fast-export: Omit tags that tag trees

Commit c0582c53bcf4e83bba70e1ad23abbad31f96ebc8 introduced logic to just omit tags that point to tree objects. However, these objects were still being output and were pointing at "mark :0", which caused fast-import to crash. This patch makes sure such tags (including deeper nestings such as tags of tags of trees), are omitted. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Jun 25, 2009 at 22:48 UTC 02c48cd69b3ebfac3867f0f9ceb1503a5af118fc
2 files changed +22 -1
builtin-fast-export.c
+15
@@ -289,6 +289,21 @@ static void handle_tag(const char *name, struct tag *tag)
289 char *buf;
290 const char *tagger, *tagger_end, *message;
291 size_t message_size = 0;
292 + struct object *tagged;
293 +
294 + /* Trees have no identifer in fast-export output, thus we have no way
295 + * to output tags of trees, tags of tags of trees, etc. Simply omit
296 + * such tags.
297 + */
298 + tagged = tag->tagged;
299 + while (tagged->type == OBJ_TAG) {
300 + tagged = ((struct tag *)tagged)->tagged;
301 + }
302 + if (tagged->type == OBJ_TREE) {
303 + warning("Omitting tag %s,\nsince tags of trees (or tags of tags of trees, etc.) are not supported.",
304 + sha1_to_hex(tag->object.sha1));
305 + return;
306 + }
307
308 buf = read_sha1_file(tag->object.sha1, &type, &size);
309 if (!buf)
t/t9301-fast-export.sh
+7 -1
@@ -271,8 +271,14 @@ test_expect_success 'set-up a few more tags for tag export tests' '
271 git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj
272 '
273
274 +test_expect_success 'tree_tag' '
275 + mkdir result &&
276 + (cd result && git init) &&
277 + git fast-export tree_tag > fe-stream &&
278 + (cd result && git fast-import < ../fe-stream)
279 +'
280 +
281 # NEEDSWORK: not just check return status, but validate the output
275 -test_expect_success 'tree_tag' 'git fast-export tree_tag'
282 test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj'
283 test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag'
284 test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'