X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-fast-export.c;h=e508ced6ba13954580632da50d789f221a132224;hb=c455c87c5cd42bbbe586b31cea1143132f3a39e4;hp=45786ef1b740c1e21c1cffeeea89cb0250f446c5;hpb=159e639e5bf24d78b22802934ae335413b2aa6ae;p=git.git diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 45786ef1b..e508ced6b 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -13,12 +13,12 @@ #include "log-tree.h" #include "revision.h" #include "decorate.h" -#include "path-list.h" +#include "string-list.h" #include "utf8.h" #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, @@ -298,7 +309,7 @@ static void handle_tag(const char *name, struct tag *tag) } static void get_tags_and_duplicates(struct object_array *pending, - struct path_list *extra_refs) + struct string_list *extra_refs) { struct tag *tag; int i; @@ -319,7 +330,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) { - path_list_insert(full_name, extra_refs)->util = tag; + string_list_insert(full_name, extra_refs)->util = tag; tag = (struct tag *)tag->tagged; } if (!tag) @@ -339,19 +350,19 @@ static void get_tags_and_duplicates(struct object_array *pending, } if (commit->util) /* more than one name for the same object */ - path_list_insert(full_name, extra_refs)->util = commit; + string_list_insert(full_name, extra_refs)->util = commit; else commit->util = full_name; } } -static void handle_tags_and_duplicates(struct path_list *extra_refs) +static void handle_tags_and_duplicates(struct string_list *extra_refs) { struct commit *commit; int i; for (i = extra_refs->nr - 1; i >= 0; i--) { - const char *name = extra_refs->items[i].path; + const char *name = extra_refs->items[i].string; struct object *object = extra_refs->items[i].util; switch (object->type) { case OBJ_TAG: @@ -379,19 +390,19 @@ static void export_marks(char *file) if (!f) error("Unable to open marks file %s for writing", file); - for (i = 0; i < idnums.size; ++i) { - deco++; - if (deco && deco->base && deco->base->type == 1) { + 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)); } + deco++; } if (ferror(f) || fclose(f)) error("Unable to write marks file %s.", file); } -static void import_marks(char * input_file) +static void import_marks(char *input_file) { char line[512]; FILE *f = fopen(input_file, "r"); @@ -407,7 +418,7 @@ static void import_marks(char * input_file) line_end = strchr(line, '\n'); if (line[0] != ':' || !line_end) die("corrupt mark line: %s", line); - *line_end = 0; + *line_end = '\0'; mark = strtoumax(line + 1, &mark_end, 10); if (!mark || mark_end == line + 1 @@ -434,7 +445,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) { struct rev_info revs; struct object_array commits = { 0, 0, NULL }; - struct path_list extra_refs = { NULL, 0, 0, 0 }; + struct string_list extra_refs = { NULL, 0, 0, 0 }; struct commit *commit; char *export_filename = NULL, *import_filename = NULL; struct option options[] = {