From patchwork Tue Oct 12 17:42:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12553371 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 885F8C433F5 for ; Tue, 12 Oct 2021 17:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7199760F3A for ; Tue, 12 Oct 2021 17:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232650AbhJLRoq (ORCPT ); Tue, 12 Oct 2021 13:44:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232648AbhJLRom (ORCPT ); Tue, 12 Oct 2021 13:44:42 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6764AC061746 for ; Tue, 12 Oct 2021 10:42:40 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id q193-20020a252aca000000b005ba63482993so212509ybq.0 for ; Tue, 12 Oct 2021 10:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=LYW6LVrfeBCSlrGae4y9Zw+nz2Abnt85V453VO/I4CM=; b=edStZw6kYmgftVgQOORILv+KKYZmByXPr/q8WLnxMWhxyh/GrU+jKJned+ittozkTw ZJ8A0Y/3PRvXfKFa0anJ3fFhSZ8d4+2M5TKi+NTvXF54lMllWbSkqN78/YRKDdjTO7ze JMkGbERSQPuctHbA+F1S9Wt/lJuOXVE5QOSFA53eBdA/lPQT/6huPGl4OSqOVxCnTdiS I9YHY7sUNM82qj+rUtaoj4B9q7uuIfxuOTg57ts9viXIF6t5/U5gG0SACDzb11rKHlPp TFEGfBPkbZugMeoj7Z7GdkIbMZwRB1uWwdakbkgP1Zx9l+Vha/HD45abu6z2n/eNUHEZ hYYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=LYW6LVrfeBCSlrGae4y9Zw+nz2Abnt85V453VO/I4CM=; b=ZcTb5R7qUQnx82EwSuTU5VmJeH+TE0XHVE19Mt9tEb9jU69ZI7cTafx7t8/F5R+D2W i+CcB9WG5YjBXM+0HTkrBtlYev597oxhR7BgA/FwnpIL5vvoHVRxjkxVowukocJyN4lv LKl5IaH7kMEBL4ct39xYUTNWDy1V5aLlVpW73vgoevAE9ApU1wIal8AzIc84B718bwNl MQO4+4ZW7YO2KiUz5t2HunxP14UpPlJv+J0Ixv7tTl8sUnEKu1Yf4/x7SmLRNURXj26Z mnib2TU41OtyWtsk201PIvym3L9slb98zIOk+oIvaxst6LTwILssM1OUMiYNv8WwSUrx zWjg== X-Gm-Message-State: AOAM530tKaUobnbwiEGcTfEz2p9eqOLCmHpU9KbEdCiIewfBEJ+yPoyI DEqf7jy+IBKO7FjsOCUvEHutrqbdPQagvBPyk6cC1FEQTTdJbFHebdCtR+tPPvkuKpobb/YTRYK 1qL16BzRt2m7I1YCKuIUUAIcYUt4WpdXmp2B34mxJQ6xM1nqn8agricJaRxPvc90= X-Google-Smtp-Source: ABdhPJyr0Fio+wTA9IgSd6PtFFRmX8JUCM48R8EV7aWVE4atBj9Hlc/jZ+ADPpdaN/PGBiON5GlPNYOe+m4nqw== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a25:3620:: with SMTP id d32mr29797836yba.46.1634060559481; Tue, 12 Oct 2021 10:42:39 -0700 (PDT) Date: Tue, 12 Oct 2021 10:42:06 -0700 In-Reply-To: <20211012174208.95161-1-chooglen@google.com> Message-Id: <20211012174208.95161-2-chooglen@google.com> Mime-Version: 1.0 References: <20211005001931.13932-1-chooglen@google.com> <20211012174208.95161-1-chooglen@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH v4 1/3] fsck: verify commit graph when implicitly enabled From: Glen Choo To: git@vger.kernel.org Cc: Eric Sunshine , Taylor Blau , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= " , Junio C Hamano , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change fsck to check the "core_commit_graph" variable set in "repo-settings.c" instead of reading the "core.commitGraph" variable. This fixes a bug where we wouldn't verify the commit-graph if the config key was missing. This bug was introduced in 31b1de6a09 (commit-graph: turn on commit-graph by default, 2019-08-13), where core.commitGraph was turned on by default. Add tests to "t5318-commit-graph.sh" to verify that fsck checks the commit-graph as expected for the 3 values of core.commitGraph. Also, disable GIT_TEST_COMMIT_GRAPH for tests that use fsck in ways that assume that commit-graph checking is disabled (t/t3800-mktag.sh, t/t0410-partial-clone.sh). Helped-by: Ævar Arnfjörð Bjarmason Signed-off-by: Glen Choo --- builtin/fsck.c | 3 ++- t/t0410-partial-clone.sh | 6 +++++- t/t3800-mktag.sh | 5 +++++ t/t5318-commit-graph.sh | 23 ++++++++++++++++++++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index b42b6fe21f..1c4e485b66 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -803,6 +803,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) fsck_enable_object_names(&fsck_walk_options); git_config(git_fsck_config, &fsck_obj_options); + prepare_repo_settings(the_repository); if (connectivity_only) { for_each_loose_object(mark_loose_for_connectivity, NULL, 0); @@ -908,7 +909,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) check_connectivity(); - if (!git_config_get_bool("core.commitgraph", &i) && i) { + if (the_repository->settings.core_commit_graph) { struct child_process commit_graph_verify = CHILD_PROCESS_INIT; const char *verify_argv[] = { "commit-graph", "verify", NULL, NULL, NULL }; diff --git a/t/t0410-partial-clone.sh b/t/t0410-partial-clone.sh index bba679685f..c76485b1b6 100755 --- a/t/t0410-partial-clone.sh +++ b/t/t0410-partial-clone.sh @@ -6,6 +6,10 @@ test_description='partial clone' # missing promisor objects cause repacks which write bitmaps to fail GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 +# When enabled, some commands will write commit-graphs. This causes fsck +# to fail when delete_object() is called because fsck will attempt to +# verify the out-of-sync commit graph. +GIT_TEST_COMMIT_GRAPH=0 delete_object () { rm $1/.git/objects/$(echo $2 | sed -e 's|^..|&/|') @@ -322,7 +326,7 @@ test_expect_success 'rev-list stops traversal at missing and promised commit' ' git -C repo config core.repositoryformatversion 1 && git -C repo config extensions.partialclone "arbitrary string" && - GIT_TEST_COMMIT_GRAPH=0 git -C repo -c core.commitGraph=false rev-list --exclude-promisor-objects --objects bar >out && + git -C repo rev-list --exclude-promisor-objects --objects bar >out && grep $(git -C repo rev-parse bar) out && ! grep $FOO out ' diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index 0544d58a6e..27fb15c83b 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -6,6 +6,11 @@ test_description='git mktag: tag object verify test' . ./test-lib.sh +# When enabled, some commands will automatically write commit-graphs. +# This will cause the mktag tests to fail because fsck will attempt to +# verify the out-of-sync commit graph. +GIT_TEST_COMMIT_GRAPH=0 + ########################################################### # check the tag.sig file, expecting verify_tag() to fail, # and checking that the error message matches the pattern diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index 295c5bd94d..4e4450af1e 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -693,12 +693,33 @@ test_expect_success 'detect incorrect chunk count' ' $GRAPH_CHUNK_LOOKUP_OFFSET ' -test_expect_success 'git fsck (checks commit-graph)' ' +test_expect_success 'git fsck (checks commit-graph when config set to true)' ' cd "$TRASH_DIRECTORY/full" && git fsck && corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \ "incorrect checksum" && cp commit-graph-pre-write-test $objdir/info/commit-graph && + test_must_fail git -c core.commitGraph=true fsck +' + +test_expect_success 'git fsck (ignores commit-graph when config set to false)' ' + cd "$TRASH_DIRECTORY/full" && + git fsck && + corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \ + "incorrect checksum" && + cp commit-graph-pre-write-test $objdir/info/commit-graph && + git -c core.commitGraph=false fsck +' + +test_expect_success 'git fsck (checks commit-graph when config unset)' ' + cd "$TRASH_DIRECTORY/full" && + test_when_finished "git config core.commitGraph true" && + + git fsck && + corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \ + "incorrect checksum" && + test_unconfig core.commitGraph && + cp commit-graph-pre-write-test $objdir/info/commit-graph && test_must_fail git fsck ' From patchwork Tue Oct 12 17:42:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12553373 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34E7EC433EF for ; Tue, 12 Oct 2021 17:42:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 210E86109E for ; Tue, 12 Oct 2021 17:42:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232699AbhJLRor (ORCPT ); Tue, 12 Oct 2021 13:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232654AbhJLRoo (ORCPT ); Tue, 12 Oct 2021 13:44:44 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E6D0C061749 for ; Tue, 12 Oct 2021 10:42:42 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id x16-20020a25b910000000b005b6b7f2f91cso169780ybj.1 for ; Tue, 12 Oct 2021 10:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=9T1h04Eih6Of+i2mDz9JDnho3wH3tZN1ibZDMTT3UoE=; b=QzdWg3kQUptcbVMvZSTegj38AkDrqJVUxfAgSw+ZBkBI/Lfo1Fw478c3r9I7o3Ejww v9mJLOwWZgqIjZHFFI/2E/P2U+hT4u7/uN5MOesqN29hQYzirIMy24ZsF0UXEtFBNdTs pxl6J32ZurvnNZuaqpNqId8/oXoLY7pg0m4NNI2bP+pNpsY6fQpfpJ+71aQ7lW7FC783 fx8PcpOOab/bKfZUSHIdBNFQr/n9nQY4lsHXzEMR0C0abkQNtxMF0ASDR370XxyLvmzr AW/vaHKtJcPhIDKvHKKqycnbvJ6Co5KP02HSPaFOgsrtZZCtBY8G1cCrLqjJ9WGPvbFs KmyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=9T1h04Eih6Of+i2mDz9JDnho3wH3tZN1ibZDMTT3UoE=; b=FIn4jw0ZaVjltXSQeX5b8VjxXYAmBXvbPPwHzdLbwcr5g87KG2pjUBzuwrXDvul/wF 6BoPwkFLmsQxwSFNhcauAevQr8ue7hd5VSIUBUQSERJ2ez2ObFRPyBYRsGe9r9THUfaQ 5vuZIPIj+27BcHeaJpLgSltJ/1XKc/zTbQwoFR4hCrh1GR7EibD7TqZqjWaAAIux5nNF K8ut3OxO2HZ96Ly/egHIwb/wg0/d/8oznN/RU3FyRqmNFBNhGDPJ4Lo1DviIjWPuGAov JoAUahCDygnYs65Ae+G0INyJlHrnrpvnRrgPAMCxoUGDbG5uTc8LIXF+T5d7TMXvkzfp pXkA== X-Gm-Message-State: AOAM532WOSfcxj6GwsD5qeyPvaSTA5HESWNewklU1mlrIrtfE1mX95aE DaZRPbtLftp4WHfzwM8nx5FJFIlV7DAR/UcZXs3ynnGGyNZkwmH+I/t2PaXe8uJV3zfn4OAcJOw n7LRyNtR6ni/z99QBe212cz/YEETFI+EbfTvvDbPXP0hQSbENGFipYv63bYUhpN4= X-Google-Smtp-Source: ABdhPJyjtcmoyXS6aGc24bERI3195TvBwNRG4GFjk8DIz0NJfl1Gvy3XxeVFL0le0XHv6ghLKwnetLXf+5FXqQ== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a25:244e:: with SMTP id k75mr28994795ybk.346.1634060561439; Tue, 12 Oct 2021 10:42:41 -0700 (PDT) Date: Tue, 12 Oct 2021 10:42:07 -0700 In-Reply-To: <20211012174208.95161-1-chooglen@google.com> Message-Id: <20211012174208.95161-3-chooglen@google.com> Mime-Version: 1.0 References: <20211005001931.13932-1-chooglen@google.com> <20211012174208.95161-1-chooglen@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH v4 2/3] fsck: verify multi-pack-index when implictly enabled From: Glen Choo To: git@vger.kernel.org Cc: Eric Sunshine , Taylor Blau , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= " , Junio C Hamano , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Like the previous commit, change fsck to check the "core_multi_pack_index" variable set in "repo-settings.c" instead of reading the "core.multiPackIndex" config variable. This fixes a bug where we wouldn't verify midx if the config key was missing. This bug was introduced in 18e449f86b (midx: enable core.multiPackIndex by default, 2020-09-25) where core.multiPackIndex was turned on by default. Helped-by: Ævar Arnfjörð Bjarmason Signed-off-by: Glen Choo --- builtin/fsck.c | 2 +- t/t5319-multi-pack-index.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index 1c4e485b66..5bbe8068ec 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -925,7 +925,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) } } - if (!git_config_get_bool("core.multipackindex", &i) && i) { + if (the_repository->settings.core_multi_pack_index) { struct child_process midx_verify = CHILD_PROCESS_INIT; const char *midx_argv[] = { "multi-pack-index", "verify", NULL, NULL, NULL }; diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh index bd17f308b3..38999f115f 100755 --- a/t/t5319-multi-pack-index.sh +++ b/t/t5319-multi-pack-index.sh @@ -452,7 +452,10 @@ test_expect_success 'verify incorrect offset' ' test_expect_success 'git-fsck incorrect offset' ' corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \ "incorrect object offset" \ - "git -c core.multipackindex=true fsck" + "git -c core.multiPackIndex=true fsck" && + test_unconfig core.multiPackIndex && + test_must_fail git fsck && + git -c core.multiPackIndex=false fsck ' test_expect_success 'corrupt MIDX is not reused' ' From patchwork Tue Oct 12 17:42:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12553375 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43040C433FE for ; Tue, 12 Oct 2021 17:42:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E6C1610CC for ; Tue, 12 Oct 2021 17:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232792AbhJLRot (ORCPT ); Tue, 12 Oct 2021 13:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232608AbhJLRop (ORCPT ); Tue, 12 Oct 2021 13:44:45 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC54C061753 for ; Tue, 12 Oct 2021 10:42:43 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id ge16-20020a17090b0e1000b001a06598a6e2so154306pjb.0 for ; Tue, 12 Oct 2021 10:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=XT7UuvjvDNjhu3lzzVi+jQFb4RArdnvsMeEnZPjndI4=; b=j79N1MoB9XMbAukSjbMO3W+59vdIJ9mM+cq0a48qe//m6so/qFd8YYweF4he1+hdxd wNLcvX8SX5/YYnaKnAHLCcKuDep9wMBsqh6Y6RJQU1tE4gD76yO6zwx++BcVKl3zaBpW ZuzCqk7HiZMU0l0w4CPH/f/3NL1qljXtRscwR+ITTQKB0gLyBYRSd+tHdcOIazvMX+/U QJw71l7aBECEPy6IIpR+BDE8UUlxmdyCYT9UbRSsKJJecJZhiKWe88tmLams0txWUTnO f7TcNCpRRuveFVRn3aqQz7eVjj9t8ErUZ9kr4go7OgpV0MMdJtzGU4Ia9gPZ/Q6ggCQq /xrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=XT7UuvjvDNjhu3lzzVi+jQFb4RArdnvsMeEnZPjndI4=; b=b1swu6aD/kHQ/rsNh6EKjg7vYbqMjlxXGgh77zLmZn1vqo2OettMq8qKTkoM2BmNR8 SsPI77CkElbdfSM+RGX32gQsuekwuc+mAkQaNO2QL57D5SC9zlliOKB60hx28s+AO1c4 lS/1aCKgRIRxq6EeMhVph3ejHMjqBO3hpQYgSOsyBTVLiZeyXg5dKizh/bSs/097IBTv 9APqxv4sw4cRWSNHCpO5c4rFGYn5FL7EDCeI8EnA3ZocW5aCsH1qL3zZMnLi9l+zS4xe G/2XqQuj6Pib202wtZ11pb7rVYXbrxbJfEkdu9FOG2DU5andBYagRJhfGfV0Oi+nUBAe 24UA== X-Gm-Message-State: AOAM532Xto7VT/d3fH8w0kH9oAV0YnQc1jBkhKLWjJGBdh5KfQzCZFjX Xdq5jQQsSUdttszoKmOGtO23VBH4Mh/2UCYv+9jLPk8gDJkVINx/U5llL7IVhDImOLwY74F2/CD JV8/JE8y4+5+9VeKpEAjvIBWXEfc0E/RQxFm6sIJC8d2Lz63gSR4niLvyXCd1PpQ= X-Google-Smtp-Source: ABdhPJw3wTOoW5gMSGuENjQUuTvdihlvWEn+ULEXxVeiE6EEaEjyU1+aj6U9N/Y/PtOP+jymn574vs94Ra+0sQ== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a63:3d4c:: with SMTP id k73mr23987299pga.44.1634060563071; Tue, 12 Oct 2021 10:42:43 -0700 (PDT) Date: Tue, 12 Oct 2021 10:42:08 -0700 In-Reply-To: <20211012174208.95161-1-chooglen@google.com> Message-Id: <20211012174208.95161-4-chooglen@google.com> Mime-Version: 1.0 References: <20211005001931.13932-1-chooglen@google.com> <20211012174208.95161-1-chooglen@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH v4 3/3] gc: perform incremental repack when implictly enabled From: Glen Choo To: git@vger.kernel.org Cc: Eric Sunshine , Taylor Blau , " =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= " , Junio C Hamano , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org builtin/gc.c has two ways of checking if multi-pack-index is enabled: - git_config_get_bool() in incremental_repack_auto_condition() - the_repository->settings.core_multi_pack_index in maintenance_task_incremental_repack() The two implementations have existed since the incremental-repack task was introduced in e841a79a13 (maintenance: add incremental-repack auto condition, 2020-09-25). These two values can diverge because prepare_repo_settings() enables the feature in the_repository->settings by default. In the case where core.multiPackIndex is not set in the config, the auto condition would fail, causing the incremental-repack task to not be run. Because we always want to consider the default values, we should always use the_repository->settings. Standardize on using the_repository->settings.core_multi_pack_index to check if multi-pack-index is enabled. Signed-off-by: Glen Choo --- builtin/gc.c | 5 ++--- t/t7900-maintenance.sh | 28 ++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/builtin/gc.c b/builtin/gc.c index 6b3de3dd51..2670931160 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1049,12 +1049,11 @@ static int maintenance_task_loose_objects(struct maintenance_run_opts *opts) static int incremental_repack_auto_condition(void) { struct packed_git *p; - int enabled; int incremental_repack_auto_limit = 10; int count = 0; - if (git_config_get_bool("core.multiPackIndex", &enabled) || - !enabled) + prepare_repo_settings(the_repository); + if (!the_repository->settings.core_multi_pack_index) return 0; git_config_get_int("maintenance.incremental-repack.auto", diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 9b9f11a8e7..74aa638475 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -336,15 +336,15 @@ test_expect_success EXPENSIVE 'incremental-repack 2g limit' ' --no-progress --batch-size=2147483647 /dev/null && test_subcommand ! git multi-pack-index write --no-progress /dev/null && test_subcommand ! git multi-pack-index write --no-progress /dev/null && test_subcommand git multi-pack-index write --no-progress