From patchwork Fri Mar 25 19:02:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12791930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13BB3C433F5 for ; Fri, 25 Mar 2022 19:27:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbiCYT3G (ORCPT ); Fri, 25 Mar 2022 15:29:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbiCYT25 (ORCPT ); Fri, 25 Mar 2022 15:28:57 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3251B1EDA15 for ; Fri, 25 Mar 2022 12:02:51 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id k124-20020a1ca182000000b0038c9cf6e2a6so4953753wme.0 for ; Fri, 25 Mar 2022 12:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=zYPbOmp0UZ7wKG2ZlzAJ4yOnCp946+BWBwpR6jqJJm0=; b=kHdAGqjZseEAFe0ENRoLRVCKmO4uyAI/NTsy1a0sgoe8tWzft1Ia48PxjV9vSUac6E G2/bSbrUCHg5yf89gyQXDBVLLI27ecZOo4R4qhuuhoL/BJZURR5qGjUjdb8JB/E2P2PM RzIA2YrT0U1c6qzles+VDhFp/xdaKaZZ4hrtpuSoGE2R3fv3dzzTVwCoUONhHUEAgUyc t5ejrSPnbIqaxkrS92Tfy3zFrvhAp7+WYrvSfuoTgYZ+YPHLDdjpETpZ+gfU0wYonN8y 58src2AR3MtBwLErwgXw+NrzF8/QnLfQehy4D60O2y+Rom/WcliTqqb0IOGV64qEi/SA LiNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=zYPbOmp0UZ7wKG2ZlzAJ4yOnCp946+BWBwpR6jqJJm0=; b=EMpO/Sx9u0TuqFg0UUXb9BbQ0WrwR9jtcDCEonKk0OzWXymEXTVPzzcTySEQ3MIKU+ TqAG78718Jr1mt/1ll19uF5b4IVRdDArUQ8AHoNHATgcxQkN7IlmxEJaFzdWzhWJguKh hqdofIyZARJu/mvocJ+78gug/0Abfja/bvRunaghXLp3dTjRBRI5LwWoWJWOx/cveaj9 qCH1sOC+qgcYnxHpssL1w1rLOLni2sm5LJ2gqCF+PTbnxV4YBXL/N1orHRX5Ii+YVrpd cIQ+Iobq8GS0Pqsiz/PpqH9QXbr5FwDC9Cl+OqPwtcB92MWvtmjCFgtJYXH9HY0Rvbb+ Brtg== X-Gm-Message-State: AOAM531mYdNha2MKOycuL6pF9Q0OUzXKmLgxWbRjiWO5d7R8JY2e7Zis Q4BYfoUQovcrjs2/YIbZ7aCCF0CLEtI= X-Google-Smtp-Source: ABdhPJwogoOojurpydaOrgqmRWr27sg8pOBty/GWnl9tQ8xppsg9ye48h4GxmOZ0kq75tVvXQO6c0w== X-Received: by 2002:a1c:3587:0:b0:381:50ff:cbd with SMTP id c129-20020a1c3587000000b0038150ff0cbdmr20856160wma.140.1648234969548; Fri, 25 Mar 2022 12:02:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c028700b0038cc9bfe6a4sm4883089wmk.37.2022.03.25.12.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:02:49 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Fri, 25 Mar 2022 19:02:46 +0000 Subject: [PATCH v3 1/2] t7700: check post-condition in kept-pack test Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, chakrabortyabhradeep79@gmail.com, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The '--write-midx -b packs non-kept objects' test in t7700-repack.sh uses test_subcommand_inexact to check that 'git repack' properly adds the '--honor-pack-keep' flag to the 'git pack-objects' subcommand. However, the test_subcommand_inexact helper is more flexible than initially designed, and this instance is the only one that makes use of it: there are additional arguments between 'git pack-objects' and the '--honor-pack-keep' flag. In order to make test_subcommand_inexact more strict, we need to fix this instance. This test checks that 'git repack --write-midx -a -b -d' will create a new pack-file that does not contain the objects within the kept pack. This behavior is possible because of the multi-pack-index bitmap that will bitmap objects against multiple packs. Without --write-midx, the objects in the kept pack would be duplicated so the resulting pack is closed under reachability and bitmaps can be created against it. This is discussed in more detail in e4d0c11c0 (repack: respect kept objects with '--write-midx -b', 2021-12-20) which also introduced this instance of test_subcommand_inexact. To better verify the intended post-conditions while also removing this instance of test_subcommand_inexact, rewrite the test to check the list of packed objects in the kept pack and the list of the objects in the newly-repacked pack-file _other_ than the kept pack. These lists should be disjoint. Be sure to include a non-kept pack-file and loose objects to be extra careful that this is properly behaving with kept packs and not just avoiding repacking all pack-files. Co-authored-by: Taylor Blau Signed-off-by: Taylor Blau Signed-off-by: Derrick Stolee --- t/t7700-repack.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 770d1432046..ca45c4cd2c1 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -369,10 +369,61 @@ test_expect_success '--write-midx with preferred bitmap tips' ' ) ' +# The first argument is expected to be a filename +# and that file should contain the name of a .idx +# file. Send the list of objects in that .idx file +# into stdout. +get_sorted_objects_from_pack () { + git show-index <$(cat "$1") >raw && + cut -d" " -f2 raw +} + test_expect_success '--write-midx -b packs non-kept objects' ' - GIT_TRACE2_EVENT="$(pwd)/trace.txt" \ - git repack --write-midx -a -b && - test_subcommand_inexact git pack-objects --honor-pack-keep before && + test_line_count = 1 before && + before_name=$(cat before) && + >${before_name%.idx}.keep && + + # Create a non-kept pack-file + test_commit other && + git repack && + + # Create loose objects + test_commit loose && + + # Repack everything + git repack --write-midx -a -b -d && + + # There should be two pack-files now, the + # old, kept pack and the new, non-kept pack. + find $objdir/pack -name "*.idx" | sort >after && + test_line_count = 2 after && + find $objdir/pack -name "*.keep" >kept && + kept_name=$(cat kept) && + echo ${kept_name%.keep}.idx >kept-idx && + test_cmp before kept-idx && + + # Get object list from the kept pack. + get_sorted_objects_from_pack before >old.objects && + + # Get object list from the one non-kept pack-file + comm -13 before after >new-pack && + test_line_count = 1 new-pack && + get_sorted_objects_from_pack new-pack >new.objects && + + # None of the objects in the new pack should + # exist within the kept pack. + comm -12 old.objects new.objects >shared.objects && + test_must_be_empty shared.objects + ) ' test_expect_success TTY '--quiet disables progress' ' From patchwork Fri Mar 25 19:02:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12791931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CFB9C433EF for ; Fri, 25 Mar 2022 19:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbiCYT3H (ORCPT ); Fri, 25 Mar 2022 15:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiCYT26 (ORCPT ); Fri, 25 Mar 2022 15:28:58 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6989021F778 for ; Fri, 25 Mar 2022 12:02:52 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id r7so10959961wrc.0 for ; Fri, 25 Mar 2022 12:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=HWcYd7OiwrwoD9+q/gpkzK4ZOE5lCSHquCeonyF4YVc=; b=b1CXxZ+YxEi2ySiNpzd/nCDJIVaWpu6ReJV0856oKiiF9uulo4XBr4TgdYodBMEmx7 gufqxVOZ4jHTiRjLI9II1g0s6a+45//Vm6iNV12KXrwDCoBtSMBXv4k9sKP/7XcJGNH9 KL5PgHk/kcO7RqUf1AC2X/rbIFd/SVPoASoL+la7xyujiMXuq+2KIKLJKuK2vuUxmNbM cYH43UCIX0jMY1Xv6pTWn1cD8IoPRnuGDB54z/HNgBwIQqa7roImhK1o3ByVz99V5qT1 YgVafYplSgxnSzBBVWHQefHPjSshv1p5lKD+MI8dB4Fg9d6X8toqTVeHkkb8ksCxjet7 oBig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=HWcYd7OiwrwoD9+q/gpkzK4ZOE5lCSHquCeonyF4YVc=; b=G+ne5u8g1nbdXlE4IzmxqM7IY4cImGgQ1amJc9+59/Pj99D57Fx+fkJQX/XBGmpsQg 11eIXJKvj0UqSTtW/eXZ/QIo1EQZXplTHb1z79k8pj2oQFjQU9CcqwsHPGfXv0IB7Im9 /iNBQtyzG5/YgmRnoZdWWZIcCCQkMeOi8k6NrokuLL99UFinx0uO9lFyD2qQiw8N9X20 Eh3foshkZSjvZuf2n8E6mt6Q3yK9ftXWjcEtOzkuI9+zkafCP4po48DS/oS+orXoRoMP 1G9IjvMVcz6Z9skTllgJTTFZoKhbTDtaWoJAhvDsMFEAzKPiuFRwQCaDsyz8PCnK+rt5 lqug== X-Gm-Message-State: AOAM530P/QJj51Z1KcZamPA57vymWOtHI7ngstjZWpQKGWQgcKk5m0VT vwcEvQ8t24RRgOfJ2bdWsQsMs3BVYKQ= X-Google-Smtp-Source: ABdhPJxG88sT2bzL0XY5BdnpcUnzxhz6TgJkQmoaDGbdkUQhNDNS7mazxjyZ1maDMOpy85QkW0Jf2g== X-Received: by 2002:a5d:584a:0:b0:205:86cb:dd0e with SMTP id i10-20020a5d584a000000b0020586cbdd0emr10172941wrf.578.1648234970786; Fri, 25 Mar 2022 12:02:50 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c5-20020a5d63c5000000b002040822b680sm8352495wrw.81.2022.03.25.12.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:02:50 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Fri, 25 Mar 2022 19:02:47 +0000 Subject: [PATCH v3 2/2] test-lib-functions: remove test_subcommand_inexact Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, chakrabortyabhradeep79@gmail.com, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The implementation of test_subcommand_inexact() was originally introduced in e4d0c11c0 (repack: respect kept objects with '--write-midx -b', 2021-12-20) with the intention to allow finding a subcommand based on an initial set of arguments. The inexactness was intended as a way to allow flexible options beyond that initial set, as opposed to test_subcommand() which requires that the full list of options is provided in its entirety. The implementation began by copying test_subcommand() and replaced the repeated argument 'printf' statement to append ".*" instead of "," to each argument. This caused it to be more flexible than initially intended. The previous change deleted the only use of test_subcommand_inexact, so instead of editing the helper, delete it. Helped-by: Taylor Blau Signed-off-by: Derrick Stolee --- t/test-lib-functions.sh | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 0f439c99d61..2501fc5706f 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1788,40 +1788,6 @@ test_subcommand () { fi } -# Check that the given command was invoked as part of the -# trace2-format trace on stdin, but without an exact set of -# arguments. -# -# test_subcommand [!] ... < -# -# For example, to look for an invocation of "git pack-objects" -# with the "--honor-pack-keep" argument, use -# -# GIT_TRACE2_EVENT=event.log git repack ... && -# test_subcommand git pack-objects --honor-pack-keep