Skip to content

Commit 88fbf67

Browse files
committed
fast-import: make tagger information optional
Even though newer Porcelain tools always record the tagger information when creating new tags, export/import pair should be able to faithfully reproduce ancient tag objects that lack tagger information. Signed-off-by: Junio C Hamano <[email protected]> Acked-by: Shawn O. Pearce <[email protected]>
1 parent 4e46a8d commit 88fbf67

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

fast-import.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Format of STDIN stream:
4343
4444
new_tag ::= 'tag' sp tag_str lf
4545
'from' sp (ref_str | hexsha1 | sha1exp_str | idnum) lf
46-
'tagger' sp name '<' email '>' when lf
46+
('tagger' sp name '<' email '>' when lf)?
4747
tag_msg;
4848
tag_msg ::= data;
4949
@@ -2264,23 +2264,27 @@ static void parse_new_tag(void)
22642264
read_next_command();
22652265

22662266
/* tagger ... */
2267-
if (prefixcmp(command_buf.buf, "tagger "))
2268-
die("Expected tagger command, got %s", command_buf.buf);
2269-
tagger = parse_ident(command_buf.buf + 7);
2267+
if (!prefixcmp(command_buf.buf, "tagger ")) {
2268+
tagger = parse_ident(command_buf.buf + 7);
2269+
read_next_command();
2270+
} else
2271+
tagger = NULL;
22702272

22712273
/* tag payload/message */
2272-
read_next_command();
22732274
parse_data(&msg);
22742275

22752276
/* build the tag object */
22762277
strbuf_reset(&new_data);
2278+
22772279
strbuf_addf(&new_data,
2278-
"object %s\n"
2279-
"type %s\n"
2280-
"tag %s\n"
2281-
"tagger %s\n"
2282-
"\n",
2283-
sha1_to_hex(sha1), commit_type, t->name, tagger);
2280+
"object %s\n"
2281+
"type %s\n"
2282+
"tag %s\n",
2283+
sha1_to_hex(sha1), commit_type, t->name);
2284+
if (tagger)
2285+
strbuf_addf(&new_data,
2286+
"tagger %s\n", tagger);
2287+
strbuf_addch(&new_data, '\n');
22842288
strbuf_addbuf(&new_data, &msg);
22852289
free(tagger);
22862290

t/t9300-fast-import.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ M 644 :2 file2
5656
M 644 :3 file3
5757
M 755 :4 file4
5858
59+
tag series-A
60+
from :5
61+
data <<EOF
62+
An annotated tag without a tagger
63+
EOF
64+
5965
INPUT_END
6066
test_expect_success \
6167
'A: create pack from stdin' \
@@ -101,6 +107,18 @@ test_expect_success \
101107
'A: verify file4' \
102108
'git cat-file blob master:file4 >actual && test_cmp expect actual'
103109

110+
cat >expect <<EOF
111+
object $(git rev-parse refs/heads/master)
112+
type commit
113+
tag series-A
114+
115+
An annotated tag without a tagger
116+
EOF
117+
test_expect_success 'A: verify tag/series-A' '
118+
git cat-file tag tags/series-A >actual &&
119+
test_cmp expect actual
120+
'
121+
104122
cat >expect <<EOF
105123
:2 `git rev-parse --verify master:file2`
106124
:3 `git rev-parse --verify master:file3`

0 commit comments

Comments
 (0)