Skip to content

Commit 941790d

Browse files
newrengitster
authored andcommitted
fast-export: handle nested tags
Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8d7d33c commit 941790d

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

builtin/fast-export.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -843,22 +843,28 @@ static void handle_tag(const char *name, struct tag *tag)
843843
free(buf);
844844
return;
845845
case REWRITE:
846-
if (tagged->type != OBJ_COMMIT) {
847-
die("tag %s tags unexported %s!",
848-
oid_to_hex(&tag->object.oid),
849-
type_name(tagged->type));
850-
}
851-
p = rewrite_commit((struct commit *)tagged);
852-
if (!p) {
853-
printf("reset %s\nfrom %s\n\n",
854-
name, oid_to_hex(&null_oid));
855-
free(buf);
856-
return;
846+
if (tagged->type == OBJ_TAG && !mark_tags) {
847+
die(_("Error: Cannot export nested tags unless --mark-tags is specified."));
848+
} else if (tagged->type == OBJ_COMMIT) {
849+
p = rewrite_commit((struct commit *)tagged);
850+
if (!p) {
851+
printf("reset %s\nfrom %s\n\n",
852+
name, oid_to_hex(&null_oid));
853+
free(buf);
854+
return;
855+
}
856+
tagged_mark = get_object_mark(&p->object);
857+
} else {
858+
/* tagged->type is either OBJ_BLOB or OBJ_TAG */
859+
tagged_mark = get_object_mark(tagged);
857860
}
858-
tagged_mark = get_object_mark(&p->object);
859861
}
860862
}
861863

864+
if (tagged->type == OBJ_TAG) {
865+
printf("reset %s\nfrom %s\n\n",
866+
name, oid_to_hex(&null_oid));
867+
}
862868
if (starts_with(name, "refs/tags/"))
863869
name += 10;
864870
printf("tag %s\n", name);

t/t9350-fast-export.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ test_expect_success 'handling tags of blobs' '
567567
test_cmp expect actual
568568
'
569569

570-
test_expect_failure 'handling nested tags' '
570+
test_expect_success 'handling nested tags' '
571571
git tag -a -m "This is a nested tag" nested muss &&
572572
git fast-export --mark-tags nested >output &&
573573
grep "^from $ZERO_OID$" output &&

0 commit comments

Comments
 (0)