fast-export: handle nested tags
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Oct 3, 2019 at 13:27 UTC
941790d7de6268ba22258bdfb4d0a9ade9390e19
2 files changed
+19
-13
builtin/fast-export.c
+18
-12
@@ -843,22 +843,28 @@ static void handle_tag(const char *name, struct tag *tag)
843
free(buf);
844
return;
845
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);
860
}
858
- tagged_mark = get_object_mark(&p->object);
861
}
862
}
863
864
+ if (tagged->type == OBJ_TAG) {
865
+ printf("reset %s\nfrom %s\n\n",
866
+ name, oid_to_hex(&null_oid));
867
+ }
868
if (starts_with(name, "refs/tags/"))
869
name += 10;
870
printf("tag %s\n", name);
t/t9350-fast-export.sh
+1
-1
@@ -567,7 +567,7 @@ test_expect_success 'handling tags of blobs' '
567
test_cmp expect actual
568
'
569
570
-test_expect_failure 'handling nested tags' '
570
+test_expect_success 'handling nested tags' '
571
git tag -a -m "This is a nested tag" nested muss &&
572
git fast-export --mark-tags nested >output &&
573
grep "^from $ZERO_OID$" output &&