From: Junio C Hamano Date: Sat, 20 Dec 2008 00:33:38 GMT Subject: [PATCH] fast-import: make tagger information optional Message-ID: <7vfxkj65y5.fsf@gitster.siamese.dyndns.org> In-Reply-To: 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 --- * ... and corresponding patch to fast-import may look like this. fast-import.c | 24 ++++++++++++++---------- t/t9300-fast-import.sh | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/fast-import.c b/fast-import.c index 201d4ff..d107896 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2265,23 +2265,27 @@ static void parse_new_tag(void) read_next_command(); /* tagger ... */ - if (prefixcmp(command_buf.buf, "tagger ")) - die("Expected tagger command, got %s", command_buf.buf); - tagger = parse_ident(command_buf.buf + 7); + if (!prefixcmp(command_buf.buf, "tagger ")) { + tagger = parse_ident(command_buf.buf + 7); + read_next_command(); + } else + tagger = NULL; /* tag payload/message */ - read_next_command(); parse_data(&msg); /* build the tag object */ strbuf_reset(&new_data); + strbuf_addf(&new_data, - "object %s\n" - "type %s\n" - "tag %s\n" - "tagger %s\n" - "\n", - sha1_to_hex(sha1), commit_type, t->name, tagger); + "object %s\n" + "type %s\n" + "tag %s\n", + sha1_to_hex(sha1), commit_type, t->name); + if (tagger) + strbuf_addf(&new_data, + "tagger %s\n", tagger); + strbuf_addch(&new_data, '\n'); strbuf_addbuf(&new_data, &msg); free(tagger); diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 91b5ace..5a2aaf2 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -56,6 +56,12 @@ M 644 :2 file2 M 644 :3 file3 M 755 :4 file4 +tag series-A +from :5 +data <actual && test_cmp expect actual' cat >expect <actual && + test_cmp expect actual +' + +cat >expect <