From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Ivankov Subject: [PATCH 1/2] fast-import: add tests for tagging blobs Date: Mon, 22 Aug 2011 18:10:18 +0600 Message-ID: <1314015019-6636-2-git-send-email-divanorama@gmail.com> References: <1314015019-6636-1-git-send-email-divanorama@gmail.com> Cc: Jonathan Nieder , "Shawn O. Pearce" , David Barr , Dmitry Ivankov To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Mon Aug 22 14:08:31 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QvTIp-000141-D5 for gcvg-git-2@lo.gmane.org; Mon, 22 Aug 2011 14:08:27 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751815Ab1HVMIY (ORCPT ); Mon, 22 Aug 2011 08:08:24 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:64964 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751760Ab1HVMIW (ORCPT ); Mon, 22 Aug 2011 08:08:22 -0400 Received: by bke11 with SMTP id 11so3606508bke.19 for ; Mon, 22 Aug 2011 05:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=oG+1sGRWuN/vKl8h9pwX8Ft13dfIxrfZFiQrb0VcDRI=; b=xmXpE0rL5Ry+HUytF3pbWkPnR85QxhxMiJFNxL+YcP1iMJWtFuVjqHJz6UA5yYv87S ZJvw01JMe2jzhqAv3U/Es0GOeMMXUfYFri/Wg6/CiQfuaYdGTmwq/oQkD1gTq9x14Dse gfRRwnnjLHr6ZXc1/Olc4RRiPsWogzURSUh9U= Received: by 10.204.154.90 with SMTP id n26mr898187bkw.137.1314014901257; Mon, 22 Aug 2011 05:08:21 -0700 (PDT) Received: from localhost.localdomain (117360277.convex.ru [79.172.62.237]) by mx.google.com with ESMTPS id zy5sm1908953bkb.64.2011.08.22.05.08.19 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 22 Aug 2011 05:08:20 -0700 (PDT) X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1314015019-6636-1-git-send-email-divanorama@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: fast-import allows to create an annotated tag that annotates a blob, via mark or direct sha1 specification. For mark it works, for sha1 it tries to read the object. It tries to do so via read_sha1_file, and then checks the size to be at least 46. That's weird, let's just allow to (annotated) tag any object referenced by sha1. If the object originates from our packfile, we still fail though. Signed-off-by: Dmitry Ivankov --- fast-import.c | 10 +++------- t/t9300-fast-import.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/fast-import.c b/fast-import.c index 7cc2262..0b0f598 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2690,13 +2690,9 @@ static void parse_new_tag(void) type = oe->type; hashcpy(sha1, oe->idx.sha1); } else if (!get_sha1(from, sha1)) { - unsigned long size; - char *buf; - - buf = read_sha1_file(sha1, &type, &size); - if (!buf || size < 46) - die("Not a valid commit: %s", from); - free(buf); + type = sha1_object_info(sha1, NULL); + if (type < 0) + die("Not a valid object: %s", from); } else die("Invalid ref name or SHA1 expression: %s", from); read_next_command(); diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index f256475..41f0d02 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -94,6 +94,12 @@ data <expect <actual && + test_cmp expect actual +' + +cat >expect <input <expect <actual && + test_cmp expect actual' + +test_tick +cat >input < $GIT_COMMITTER_DATE data <