Skip to content

Commit a1638cf

Browse files
newrengitster
authored andcommitted
fast-export: allow user to request tags be marked with --mark-tags
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 208d692 commit a1638cf

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

Documentation/git-fast-export.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,20 @@ produced incorrect results if you gave these options.
7575
Before processing any input, load the marks specified in
7676
<file>. The input file must exist, must be readable, and
7777
must use the same format as produced by --export-marks.
78+
79+
--mark-tags::
80+
In addition to labelling blobs and commits with mark ids, also
81+
label tags. This is useful in conjunction with
82+
`--export-marks` and `--import-marks`, and is also useful (and
83+
necessary) for exporting of nested tags. It does not hurt
84+
other cases and would be the default, but many fast-import
85+
frontends are not prepared to accept tags with mark
86+
identifiers.
7887
+
79-
Any commits that have already been marked will not be exported again.
80-
If the backend uses a similar --import-marks file, this allows for
81-
incremental bidirectional exporting of the repository by keeping the
82-
marks the same across runs.
88+
Any commits (or tags) that have already been marked will not be
89+
exported again. If the backend uses a similar --import-marks file,
90+
this allows for incremental bidirectional exporting of the repository
91+
by keeping the marks the same across runs.
8392

8493
--fake-missing-tagger::
8594
Some old repositories have tags without a tagger. The

builtin/fast-export.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ static int no_data;
4040
static int full_tree;
4141
static int reference_excluded_commits;
4242
static int show_original_ids;
43+
static int mark_tags;
4344
static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
4445
static struct string_list tag_refs = STRING_LIST_INIT_NODUP;
4546
static struct refspec refspecs = REFSPEC_INIT_FETCH;
@@ -861,6 +862,10 @@ static void handle_tag(const char *name, struct tag *tag)
861862
if (starts_with(name, "refs/tags/"))
862863
name += 10;
863864
printf("tag %s\n", name);
865+
if (mark_tags) {
866+
mark_next_object(&tag->object);
867+
printf("mark :%"PRIu32"\n", last_idnum);
868+
}
864869
if (tagged_mark)
865870
printf("from :%d\n", tagged_mark);
866871
else
@@ -1165,6 +1170,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
11651170
&reference_excluded_commits, N_("Reference parents which are not in fast-export stream by object id")),
11661171
OPT_BOOL(0, "show-original-ids", &show_original_ids,
11671172
N_("Show original object ids of blobs/commits")),
1173+
OPT_BOOL(0, "mark-tags", &mark_tags,
1174+
N_("Label tags with mark ids")),
11681175

11691176
OPT_END()
11701177
};

t/t9350-fast-export.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ test_expect_success 'fast-export ^muss^{commit} muss' '
6666
test_cmp expected actual
6767
'
6868

69+
test_expect_success 'fast-export --mark-tags ^muss^{commit} muss' '
70+
git fast-export --mark-tags --tag-of-filtered-object=rewrite ^muss^{commit} muss >actual &&
71+
cat >expected <<-EOF &&
72+
tag muss
73+
mark :1
74+
from $(git rev-parse --verify muss^{commit})
75+
$(git cat-file tag muss | grep tagger)
76+
data 9
77+
valentin
78+
79+
EOF
80+
test_cmp expected actual
81+
'
82+
6983
test_expect_success 'fast-export master~2..master' '
7084
7185
git fast-export master~2..master >actual &&

0 commit comments

Comments
 (0)