]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-fast-export.c
Merge branch 'maint'
[git.git] / builtin-fast-export.c
index 170b82e6ef18481430b5f83fd069b1726791e2de..a443d594602b3b80964763d3105aaa2480780a87 100644 (file)
@@ -18,7 +18,7 @@
 #include "parse-options.h"
 
 static const char *fast_export_usage[] = {
-       "git-fast-export [rev-list-opts]",
+       "git fast-export [rev-list-opts]",
        NULL
 };
 
@@ -116,7 +116,7 @@ static void handle_object(const unsigned char *sha1)
 
        mark_next_object(object);
 
-       printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
+       printf("blob\nmark :%"PRIu32"\ndata %lu\n", last_idnum, size);
        if (size && fwrite(buf, size, 1, stdout) != 1)
                die ("Could not write blob %s", sha1_to_hex(sha1));
        printf("\n");
@@ -136,9 +136,18 @@ static void show_filemodify(struct diff_queue_struct *q,
                if (is_null_sha1(spec->sha1))
                        printf("D %s\n", spec->path);
                else {
-                       struct object *object = lookup_object(spec->sha1);
-                       printf("M %06o :%d %s\n", spec->mode,
-                              get_object_mark(object), spec->path);
+                       /*
+                        * Links refer to objects in another repositories;
+                        * output the SHA-1 verbatim.
+                        */
+                       if (S_ISGITLINK(spec->mode))
+                               printf("M %06o %s %s\n", spec->mode,
+                                      sha1_to_hex(spec->sha1), spec->path);
+                       else {
+                               struct object *object = lookup_object(spec->sha1);
+                               printf("M %06o :%d %s\n", spec->mode,
+                                      get_object_mark(object), spec->path);
+                       }
                }
        }
 }
@@ -196,15 +205,17 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
                diff_root_tree_sha1(commit->tree->object.sha1,
                                    "", &rev->diffopt);
 
+       /* Export the referenced blobs, and remember the marks. */
        for (i = 0; i < diff_queued_diff.nr; i++)
-               handle_object(diff_queued_diff.queue[i]->two->sha1);
+               if (!S_ISGITLINK(diff_queued_diff.queue[i]->two->mode))
+                       handle_object(diff_queued_diff.queue[i]->two->sha1);
 
        mark_next_object(&commit->object);
        if (!is_encoding_utf8(encoding))
                reencoded = reencode_string(message, "UTF-8", encoding);
        if (!commit->parents)
                printf("reset %s\n", (const char*)commit->util);
-       printf("commit %s\nmark :%d\n%.*s\n%.*s\ndata %u\n%s",
+       printf("commit %s\nmark :%"PRIu32"\n%.*s\n%.*s\ndata %u\n%s",
               (const char *)commit->util, last_idnum,
               (int)(author_end - author), author,
               (int)(committer_end - committer), committer,