Code

git config: reorganize get_color*
[git.git] / builtin-fast-export.c
index 7d5d57ad7568b8c0bf7396cdbd581c67ab4600e2..e9ee2c79ac0395fde30de329d181733d7be88d40 100644 (file)
@@ -24,6 +24,7 @@ static const char *fast_export_usage[] = {
 
 static int progress;
 static enum { VERBATIM, WARN, STRIP, ABORT } signed_tag_mode = ABORT;
+static int fake_missing_tagger;
 
 static int parse_opt_signed_tag_mode(const struct option *opt,
                                     const char *arg, int unset)
@@ -297,10 +298,17 @@ static void handle_tag(const char *name, struct tag *tag)
                message_size = strlen(message);
        }
        tagger = memmem(buf, message ? message - buf : size, "\ntagger ", 8);
-       if (!tagger)
-               die ("No tagger for tag %s", sha1_to_hex(tag->object.sha1));
-       tagger++;
-       tagger_end = strchrnul(tagger, '\n');
+       if (!tagger) {
+               if (fake_missing_tagger)
+                       tagger = "tagger Unspecified Tagger "
+                               "<unspecified-tagger> 0 +0000";
+               else
+                       tagger = "";
+               tagger_end = tagger + strlen(tagger);
+       } else {
+               tagger++;
+               tagger_end = strchrnul(tagger, '\n');
+       }
 
        /* handle signed tags */
        if (message) {
@@ -326,9 +334,10 @@ static void handle_tag(const char *name, struct tag *tag)
 
        if (!prefixcmp(name, "refs/tags/"))
                name += 10;
-       printf("tag %s\nfrom :%d\n%.*s\ndata %d\n%.*s\n",
+       printf("tag %s\nfrom :%d\n%.*s%sdata %d\n%.*s\n",
               name, get_object_mark(tag->tagged),
               (int)(tagger_end - tagger), tagger,
+              tagger == tagger_end ? "" : "\n",
               (int)message_size, (int)message_size, message ? message : "");
 }
 
@@ -483,9 +492,14 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
                             "Dump marks to this file"),
                OPT_STRING(0, "import-marks", &import_filename, "FILE",
                             "Import marks from this file"),
+               OPT_BOOLEAN(0, "fake-missing-tagger", &fake_missing_tagger,
+                            "Fake a tagger when tags lack one"),
                OPT_END()
        };
 
+       if (argc == 1)
+               usage_with_options (fast_export_usage, options);
+
        /* we handle encodings */
        git_config(git_default_config, NULL);