From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: [PATCH] fast-import: make tagger information optional Date: Fri, 19 Dec 2008 16:33:38 -0800 Message-ID: <7vfxkj65y5.fsf@gitster.siamese.dyndns.org> References: <20081218164614.GS5691@genesis.frugalware.org> <7vbpv9guqd.fsf@gitster.siamese.dyndns.org> <20081218213407.GX5691@genesis.frugalware.org> <7viqphf4ua.fsf@gitster.siamese.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Johannes Schindelin , Miklos Vajna , git@vger.kernel.org, scott@canonical.com To: "Shawn O. Pearce" X-From: git-owner@vger.kernel.org Sat Dec 20 01:35:15 2008 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1LDpoC-0006XV-Kk for gcvg-git-2@gmane.org; Sat, 20 Dec 2008 01:35:09 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752403AbYLTAdu (ORCPT ); Fri, 19 Dec 2008 19:33:50 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752514AbYLTAdu (ORCPT ); Fri, 19 Dec 2008 19:33:50 -0500 Received: from a-sasl-quonix.sasl.smtp.pobox.com ([208.72.237.25]:61266 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752325AbYLTAdu (ORCPT ); Fri, 19 Dec 2008 19:33:50 -0500 Received: from localhost.localdomain (unknown [127.0.0.1]) by b-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id A65801AAD2; Fri, 19 Dec 2008 19:33:47 -0500 (EST) Received: from pobox.com (unknown [68.225.240.211]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by b-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 325BD1AAC7; Fri, 19 Dec 2008 19:33:39 -0500 (EST) User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-Pobox-Relay-ID: DD8A84BA-CE2D-11DD-8BCD-F83E113D384A-77302942!a-sasl-quonix.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 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 <