git-p4: Support usage of perforce client spec
[gitweb.git] / builtin-fast-export.c
index 72be45db46faef46695b333a298f2857706dff9f..4bd1356d50508efab81066e79abd7abcc1443627 100755 (executable)
@@ -23,15 +23,15 @@ static const char *fast_export_usage[] = {
 };
 
 static int progress;
-static enum { IGNORE, WARN, STRIP, ABORT } signed_tag_mode = ABORT;
+static enum { VERBATIM, WARN, STRIP, ABORT } signed_tag_mode = ABORT;
 
 static int parse_opt_signed_tag_mode(const struct option *opt,
                                     const char *arg, int unset)
 {
        if (unset || !strcmp(arg, "abort"))
                signed_tag_mode = ABORT;
-       else if (!strcmp(arg, "ignore"))
-               signed_tag_mode = IGNORE;
+       else if (!strcmp(arg, "verbatim") || !strcmp(arg, "ignore"))
+               signed_tag_mode = VERBATIM;
        else if (!strcmp(arg, "warn"))
                signed_tag_mode = WARN;
        else if (!strcmp(arg, "strip"))
@@ -103,7 +103,7 @@ static void handle_object(const unsigned char *sha1)
        mark_object(object);
 
        printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
-       if (fwrite(buf, size, 1, stdout) != 1)
+       if (size && fwrite(buf, size, 1, stdout) != 1)
                die ("Could not write blob %s", sha1_to_hex(sha1));
        printf("\n");
 
@@ -123,7 +123,7 @@ static void show_filemodify(struct diff_queue_struct *q,
                        printf("D %s\n", spec->path);
                else {
                        struct object *object = lookup_object(spec->sha1);
-                       printf("M 0%06o :%d %s\n", spec->mode,
+                       printf("M %06o :%d %s\n", spec->mode,
                               get_object_mark(object), spec->path);
                }
        }
@@ -270,7 +270,7 @@ static void handle_tag(const char *name, struct tag *tag)
                                warning ("Exporting signed tag %s",
                                         sha1_to_hex(tag->object.sha1));
                                /* fallthru */
-                       case IGNORE:
+                       case VERBATIM:
                                break;
                        case STRIP:
                                message_size = signature + 1 - message;
@@ -383,7 +383,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
 
        get_tags_and_duplicates(&revs.pending, &extra_refs);
 
-       prepare_revision_walk(&revs);
+       if (prepare_revision_walk(&revs))
+               die("revision walk setup failed");
        revs.diffopt.format_callback = show_filemodify;
        DIFF_OPT_SET(&revs.diffopt, RECURSIVE);
        while ((commit = get_revision(&revs))) {