Skip to content

Commit f73b2ab

Browse files
newrengitster
authored andcommitted
fast-import: allow tags to be identified by mark labels
Mark identifiers are used in fast-export and fast-import to provide a label to refer to earlier content. Blobs are given labels because they need to be referenced in the commits where they first appear with a given filename, and commits are given labels because they can be the parents of other commits. Tags were never given labels, probably because they were viewed as unnecessary, but that presents two problems: 1. It leaves us without a way of referring to previous tags if we want to create a tag of a tag (or higher nestings). 2. It leaves us with no way of recording that a tag has already been imported when using --export-marks and --import-marks. Fix these problems by allowing an optional mark label for tags. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3164e6b commit f73b2ab

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Documentation/git-fast-import.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ lightweight (non-annotated) tags see the `reset` command below.
774774

775775
....
776776
'tag' SP <name> LF
777+
mark?
777778
'from' SP <commit-ish> LF
778779
original-oid?
779780
'tagger' (SP <name>)? SP LT <email> GT SP <when> LF

fast-import.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2713,6 +2713,7 @@ static void parse_new_tag(const char *arg)
27132713
first_tag = t;
27142714
last_tag = t;
27152715
read_next_command();
2716+
parse_mark();
27162717

27172718
/* from ... */
27182719
if (!skip_prefix(command_buf.buf, "from ", &from))
@@ -2769,7 +2770,7 @@ static void parse_new_tag(const char *arg)
27692770
strbuf_addbuf(&new_data, &msg);
27702771
free(tagger);
27712772

2772-
if (store_object(OBJ_TAG, &new_data, NULL, &t->oid, 0))
2773+
if (store_object(OBJ_TAG, &new_data, NULL, &t->oid, next_mark))
27732774
t->pack_id = MAX_PACK_ID;
27742775
else
27752776
t->pack_id = pack_id;

t/t9300-fast-import.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@ test_expect_success 'A: create pack from stdin' '
9494
reset refs/tags/to-be-deleted
9595
from 0000000000000000000000000000000000000000
9696
97+
tag nested
98+
mark :6
99+
from :4
100+
data <<EOF
101+
Tag of our lovely commit
102+
EOF
103+
104+
reset refs/tags/nested
105+
from 0000000000000000000000000000000000000000
106+
107+
tag nested
108+
mark :7
109+
from :6
110+
data <<EOF
111+
Tag of tag of our lovely commit
112+
EOF
113+
97114
INPUT_END
98115
git fast-import --export-marks=marks.out <input &&
99116
git whatchanged master
@@ -176,6 +193,8 @@ test_expect_success 'A: verify marks output' '
176193
:3 $(git rev-parse --verify master:file3)
177194
:4 $(git rev-parse --verify master:file4)
178195
:5 $(git rev-parse --verify master^0)
196+
:6 $(git cat-file tag nested | grep object | cut -d" " -f 2)
197+
:7 $(git rev-parse --verify nested)
179198
EOF
180199
test_cmp expect marks.out
181200
'

0 commit comments

Comments
 (0)