Skip to content

Commit 02c48cd

Browse files
newrengitster
authored andcommitted
fast-export: Omit tags that tag trees
Commit c0582c5 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 668f3aa commit 02c48cd

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

builtin-fast-export.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,21 @@ static void handle_tag(const char *name, struct tag *tag)
289289
char *buf;
290290
const char *tagger, *tagger_end, *message;
291291
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+
}
292307

293308
buf = read_sha1_file(tag->object.sha1, &type, &size);
294309
if (!buf)

t/t9301-fast-export.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,14 @@ test_expect_success 'set-up a few more tags for tag export tests' '
271271
git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj
272272
'
273273

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+
274281
# NEEDSWORK: not just check return status, but validate the output
275-
test_expect_success 'tree_tag' 'git fast-export tree_tag'
276282
test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj'
277283
test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag'
278284
test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'

0 commit comments

Comments
 (0)