From patchwork Mon Jun 21 22:25:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12335821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 478A5C48BC2 for ; Mon, 21 Jun 2021 22:25:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D0D760FE9 for ; Mon, 21 Jun 2021 22:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232267AbhFUW15 (ORCPT ); Mon, 21 Jun 2021 18:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232181AbhFUW14 (ORCPT ); Mon, 21 Jun 2021 18:27:56 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7499C061574 for ; Mon, 21 Jun 2021 15:25:41 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id k5so3126277ilv.8 for ; Mon, 21 Jun 2021 15:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZPrEzB0xIK/wOTqk4WBQW79bWc96glFVTSqPVLHOsMY=; b=rMBDFyWftTGzHaFzsr5c1NMiZ2lja67Spp2qGm9DGOZX9p2wLHc9vkhnDBTpmgi1bF vG7UCcmU/sWmQQbi9a+emoZqFaY7QT0Nv+FDqAmr6d3xzgVrU58t7qxjd0f1AsRYx5gG WeND9a3PV0lLbOypJmj44nKbEZU9wrCPRjLC63kES/ntqT9epZgb32q1fWlVNxZqL1Ls mWR1Fx8FvUzJhgqNthXE+arpoc/hRc/uczf9vKHPPgJtZp5QEX04Tt/RpB80zuX7eG7H dJTSg1ugbUOuIhtKRFFgDGsnDacbHHrX3F7RPaI9sZRDAINXXkQHIhoIcG5AhRfUgrSU RpXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZPrEzB0xIK/wOTqk4WBQW79bWc96glFVTSqPVLHOsMY=; b=EQZbg2sFLPFn/t/6F+eZ4dCssW9h04mCyNTfzpKMoV3QiBvmfEUvEYZJdzC9d06gfV ScKYVus8eCZEynbS5jH1l/8cZF/Q4ExhyAQsrKHt5rWm3P5ZaiHpfQCqUxoGql08VmOh 86UmJqkyDxoq3kByRUeLdxQdFAJ15ATy+wSgeM0dpDdbDre0Vlxa92r6dSmOEsn4VzVq 5GEBrImEICemZt3+TtguUBt8JUutLvjweM1CCfdfn1Nr4JlufT4ulL658imEO+/SVLCE 0GaNijU8XgZi8ETra5HbA6+dlxRFdB93ZtSb7KYROnp3icnNjLm1XoAz57cwvMSG/wRI Wp0Q== X-Gm-Message-State: AOAM532JrtDvqjvhMm7+fcckDOJCfPABOAeJZ5/LDzFghcAADgOQCQKy gwbFataPc1mtKoROvtOPuJQpDGV6jpQHue+7 X-Google-Smtp-Source: ABdhPJzs0QFxJpArIRjyRCqikWuSsxEoq5oITs6cNqHt8BPS23E6kk4XmWrebfPsKR3kEgUFvtidng== X-Received: by 2002:a05:6e02:10c2:: with SMTP id s2mr364698ilj.24.1624314341144; Mon, 21 Jun 2021 15:25:41 -0700 (PDT) Received: from localhost ([2600:1700:d843:8f:f6bb:34fc:22a7:6a3]) by smtp.gmail.com with ESMTPSA id y205sm11119697iof.1.2021.06.21.15.25.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 15:25:40 -0700 (PDT) Date: Mon, 21 Jun 2021 18:25:40 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, dstolee@microsoft.com, gitster@pobox.com, jonathantanmy@google.com Subject: [PATCH v2 16/24] t/helper/test-read-midx.c: add --checksum mode Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Subsequent tests will want to check for the existence of a multi-pack bitmap which matches the multi-pack-index stored in the pack directory. The multi-pack bitmap includes the hex checksum of the MIDX it corresponds to in its filename (for example, '$packdir/multi-pack-index-.bitmap'). As a result, some tests want a way to learn what '' is. This helper addresses that need by printing the checksum of the repository's multi-pack-index. Signed-off-by: Taylor Blau --- t/helper/test-read-midx.c | 16 +++++++++++++++- t/lib-bitmap.sh | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c index 7c2eb11a8e..cb0d27049a 100644 --- a/t/helper/test-read-midx.c +++ b/t/helper/test-read-midx.c @@ -60,12 +60,26 @@ static int read_midx_file(const char *object_dir, int show_objects) return 0; } +static int read_midx_checksum(const char *object_dir) +{ + struct multi_pack_index *m; + + setup_git_directory(); + m = load_multi_pack_index(object_dir, 1); + if (!m) + return 1; + printf("%s\n", hash_to_hex(get_midx_checksum(m))); + return 0; +} + int cmd__read_midx(int argc, const char **argv) { if (!(argc == 2 || argc == 3)) - usage("read-midx [--show-objects] "); + usage("read-midx [--show-objects|--checksum] "); if (!strcmp(argv[1], "--show-objects")) return read_midx_file(argv[2], 1); + else if (!strcmp(argv[1], "--checksum")) + return read_midx_checksum(argv[2]); return read_midx_file(argv[1], 0); } diff --git a/t/lib-bitmap.sh b/t/lib-bitmap.sh index ecb5d0e05d..09cd036f4d 100644 --- a/t/lib-bitmap.sh +++ b/t/lib-bitmap.sh @@ -260,3 +260,7 @@ have_delta () { echo $1 | git cat-file --batch-check="%(deltabase)" >actual && test_cmp expect actual } + +midx_checksum () { + test-tool read-midx --checksum "${1:-.git/objects}" +}