]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fast-export: allow user to request tags be marked with --mark-tags
authorElijah Newren <newren@gmail.com>
Thu, 3 Oct 2019 20:27:07 +0000 (13:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Oct 2019 22:33:21 +0000 (07:33 +0900)
Add a new option, --mark-tags, which will output mark identifiers with
each tag object.  This improves the incremental export story with
--export-marks since it will allow us to record that annotated tags have
been exported, and it is also needed as a step towards supporting nested
tags.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-fast-export.txt
builtin/fast-export.c
t/t9350-fast-export.sh

index cc940eb9ada3ce65bd3e57af73da59b77c99acbc..c522b34f7be56e967c575dea59a3cc41b4495447 100644 (file)
@@ -75,11 +75,20 @@ produced incorrect results if you gave these options.
        Before processing any input, load the marks specified in
        <file>.  The input file must exist, must be readable, and
        must use the same format as produced by --export-marks.
+
+--mark-tags::
+       In addition to labelling blobs and commits with mark ids, also
+       label tags.  This is useful in conjunction with
+       `--export-marks` and `--import-marks`, and is also useful (and
+       necessary) for exporting of nested tags.  It does not hurt
+       other cases and would be the default, but many fast-import
+       frontends are not prepared to accept tags with mark
+       identifiers.
 +
-Any commits that have already been marked will not be exported again.
-If the backend uses a similar --import-marks file, this allows for
-incremental bidirectional exporting of the repository by keeping the
-marks the same across runs.
+Any commits (or tags) that have already been marked will not be
+exported again.  If the backend uses a similar --import-marks file,
+this allows for incremental bidirectional exporting of the repository
+by keeping the marks the same across runs.
 
 --fake-missing-tagger::
        Some old repositories have tags without a tagger.  The
index 575e47833bb37811b75b4ad5ea13cdd4f4548148..d32e1e9327570955c6732e2a3b191ceff4580774 100644 (file)
@@ -40,6 +40,7 @@ static int no_data;
 static int full_tree;
 static int reference_excluded_commits;
 static int show_original_ids;
+static int mark_tags;
 static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
 static struct string_list tag_refs = STRING_LIST_INIT_NODUP;
 static struct refspec refspecs = REFSPEC_INIT_FETCH;
@@ -861,6 +862,10 @@ static void handle_tag(const char *name, struct tag *tag)
        if (starts_with(name, "refs/tags/"))
                name += 10;
        printf("tag %s\n", name);
+       if (mark_tags) {
+               mark_next_object(&tag->object);
+               printf("mark :%"PRIu32"\n", last_idnum);
+       }
        if (tagged_mark)
                printf("from :%d\n", tagged_mark);
        else
@@ -1165,6 +1170,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
                         &reference_excluded_commits, N_("Reference parents which are not in fast-export stream by object id")),
                OPT_BOOL(0, "show-original-ids", &show_original_ids,
                            N_("Show original object ids of blobs/commits")),
+               OPT_BOOL(0, "mark-tags", &mark_tags,
+                           N_("Label tags with mark ids")),
 
                OPT_END()
        };
index ea84e2f173ec8830fa5633beebf05c7d70105048..b3fca6ffba52b26f41de7f728e41da69bcf68259 100755 (executable)
@@ -66,6 +66,20 @@ test_expect_success 'fast-export ^muss^{commit} muss' '
        test_cmp expected actual
 '
 
+test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' '
+       git fast-export --mark-tags --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual &&
+       cat >expected <<-EOF &&
+       tag muss
+       mark :1
+       from $(git rev-parse --verify muss^{commit})
+       $(git cat-file tag muss | grep tagger)
+       data 9
+       valentin
+
+       EOF
+       test_cmp expected actual
+'
+
 test_expect_success 'fast-export master~2..master' '
 
        git fast-export master~2..master >actual &&