]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-fast-export.c
fast-import: close pack before unlinking it
[thirdparty/git.git] / builtin-fast-export.c
index e508ced6ba13954580632da50d789f221a132224..7d5d57ad7568b8c0bf7396cdbd581c67ab4600e2 100644 (file)
@@ -132,10 +132,27 @@ static void show_filemodify(struct diff_queue_struct *q,
 {
        int i;
        for (i = 0; i < q->nr; i++) {
+               struct diff_filespec *ospec = q->queue[i]->one;
                struct diff_filespec *spec = q->queue[i]->two;
-               if (is_null_sha1(spec->sha1))
+
+               switch (q->queue[i]->status) {
+               case DIFF_STATUS_DELETED:
                        printf("D %s\n", spec->path);
-               else {
+                       break;
+
+               case DIFF_STATUS_COPIED:
+               case DIFF_STATUS_RENAMED:
+                       printf("%c \"%s\" \"%s\"\n", q->queue[i]->status,
+                              ospec->path, spec->path);
+
+                       if (!hashcmp(ospec->sha1, spec->sha1) &&
+                           ospec->mode == spec->mode)
+                               break;
+                       /* fallthrough */
+
+               case DIFF_STATUS_TYPE_CHANGED:
+               case DIFF_STATUS_MODIFIED:
+               case DIFF_STATUS_ADDED:
                        /*
                         * Links refer to objects in another repositories;
                         * output the SHA-1 verbatim.
@@ -148,6 +165,13 @@ static void show_filemodify(struct diff_queue_struct *q,
                                printf("M %06o :%d %s\n", spec->mode,
                                       get_object_mark(object), spec->path);
                        }
+                       break;
+
+               default:
+                       die("Unexpected comparison status '%c' for %s, %s",
+                               q->queue[i]->status,
+                               ospec->path ? ospec->path : "none",
+                               spec->path ? spec->path : "none");
                }
        }
 }
@@ -330,7 +354,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
                case OBJ_TAG:
                        tag = (struct tag *)e->item;
                        while (tag && tag->object.type == OBJ_TAG) {
-                               string_list_insert(full_name, extra_refs)->util = tag;
+                               string_list_append(full_name, extra_refs)->util = tag;
                                tag = (struct tag *)tag->tagged;
                        }
                        if (!tag)
@@ -350,7 +374,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
                }
                if (commit->util)
                        /* more than one name for the same object */
-                       string_list_insert(full_name, extra_refs)->util = commit;
+                       string_list_append(full_name, extra_refs)->util = commit;
                else
                        commit->util = full_name;
        }
@@ -393,7 +417,8 @@ static void export_marks(char *file)
        for (i = 0; i < idnums.size; i++) {
                if (deco->base && deco->base->type == 1) {
                        mark = ptr_to_mark(deco->decoration);
-                       fprintf(f, ":%u %s\n", mark, sha1_to_hex(deco->base->sha1));
+                       fprintf(f, ":%"PRIu32" %s\n", mark,
+                               sha1_to_hex(deco->base->sha1));
                }
                deco++;
        }