]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fast-export: handle nested tags
authorElijah Newren <newren@gmail.com>
Thu, 3 Oct 2019 20:27:09 +0000 (13:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Oct 2019 22:33:21 +0000 (07:33 +0900)
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fast-export.c
t/t9350-fast-export.sh

index d32e1e9327570955c6732e2a3b191ceff4580774..58a74de42a0c9bc121f3f687c355192b9841ed16 100644 (file)
@@ -843,22 +843,28 @@ static void handle_tag(const char *name, struct tag *tag)
                        free(buf);
                        return;
                case REWRITE:
-                       if (tagged->type != OBJ_COMMIT) {
-                               die("tag %s tags unexported %s!",
-                                   oid_to_hex(&tag->object.oid),
-                                   type_name(tagged->type));
-                       }
-                       p = rewrite_commit((struct commit *)tagged);
-                       if (!p) {
-                               printf("reset %s\nfrom %s\n\n",
-                                      name, oid_to_hex(&null_oid));
-                               free(buf);
-                               return;
+                       if (tagged->type == OBJ_TAG && !mark_tags) {
+                               die(_("Error: Cannot export nested tags unless --mark-tags is specified."));
+                       } else if (tagged->type == OBJ_COMMIT) {
+                               p = rewrite_commit((struct commit *)tagged);
+                               if (!p) {
+                                       printf("reset %s\nfrom %s\n\n",
+                                              name, oid_to_hex(&null_oid));
+                                       free(buf);
+                                       return;
+                               }
+                               tagged_mark = get_object_mark(&p->object);
+                       } else {
+                               /* tagged->type is either OBJ_BLOB or OBJ_TAG */
+                               tagged_mark = get_object_mark(tagged);
                        }
-                       tagged_mark = get_object_mark(&p->object);
                }
        }
 
+       if (tagged->type == OBJ_TAG) {
+               printf("reset %s\nfrom %s\n\n",
+                      name, oid_to_hex(&null_oid));
+       }
        if (starts_with(name, "refs/tags/"))
                name += 10;
        printf("tag %s\n", name);
index 9ab281e4b9d43c2b1dc310684b3de9a33bdc65ef..2e4e21481542779dab3354c0ee9b332f76ad2034 100755 (executable)
@@ -567,7 +567,7 @@ test_expect_success 'handling tags of blobs' '
        test_cmp expect actual
 '
 
-test_expect_failure 'handling nested tags' '
+test_expect_success 'handling nested tags' '
        git tag -a -m "This is a nested tag" nested muss &&
        git fast-export --mark-tags nested >output &&
        grep "^from $ZERO_OID$" output &&