From patchwork Mon Sep 13 18:12:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12490483 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=-26.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 7D34EC433F5 for ; Mon, 13 Sep 2021 18:12:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68C9F610E6 for ; Mon, 13 Sep 2021 18:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346909AbhIMSNv (ORCPT ); Mon, 13 Sep 2021 14:13:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346906AbhIMSNr (ORCPT ); Mon, 13 Sep 2021 14:13:47 -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 903F5C0613C1 for ; Mon, 13 Sep 2021 11:12:29 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id d93-20020a25a366000000b0059fff274d9aso14043642ybi.4 for ; Mon, 13 Sep 2021 11:12:29 -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=vVdjOKAWGYvMY3JRSb+4vk8XBUdsLBzb2PcmmQ/ZyNk=; b=U5UJsZJkVmgGxMYcyA/NHQbAvc0/uxKheNYl1BJ4iIy/kzv+7+6b8u8KYbvsBRPdjq rBKjMGr0gBTxUAhNiyJo39/IaYyJSOXGweD63W/uRgeg0LfBmJOlv7oFvSKq6wKj9wnO gJx7+RI0HMM2NmWLnsfVuipmZvJefzCnSKpWvm3XFhdv3CQy8gTPh+xz4upOnLAiPVe3 5BvUGRfSe5WJ8mgkRY/jUIeYbioFp8NFjfhX4wAFraFPpwTyNMSKwh1VPZ+XEqZFnu49 d+tpZLm3wK0loB0cUiVqf0h8LvKZk9rxwNyit2k8F6hF2dwDS2FR9mF2n4JL9SoitzVV S2cg== 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=vVdjOKAWGYvMY3JRSb+4vk8XBUdsLBzb2PcmmQ/ZyNk=; b=pX7+6/ljIyoC4lFZFOomfBUZdqieuw7T6WSXUjZXrRZXVLKWg+li3TkOyHXfcMQ6C1 BAolFmUdoJy5xHA7p8/dfjcbARMPh7n7NvfO3ZBf7Ewo9L41qbO3Q4Q3ufX1eRYCXFFm 7DHl079/LpgAmh7B//WAuFC0WFwSSAxeqGUf1o/rE1F9ZoQK0dZATcmsW449A/7Pujnu au2MTpJGEWSHY7XBUOz9jhxbQuxHu6E/WOZToTg/2wImLX2psEZzk9Yv8UzMnVRwEt2/ fjxLOSmBiFp8lm+E01xNOU4KF6mxYXyG7GwJUyodGuD8A3B1mIZf/3gs/XjdeheI7RnS eAQg== X-Gm-Message-State: AOAM532qNU9nkotf4Q1RtNwt2CT/EV8Yu4pw8s5STQZusIuOiPu4sjwH p0fuWnav2+BywkdWHKRs1jPv1c3FOrpEIUnkpMcuFxIhfhsWKZkk7BTSfJMn6nKEsbFaSrl6h8h vWwOPBNeJbyYPsSB6gJ7f1wt6JVGVIFgB4lGJ38knaXCAN+MreCe0RVerbcx/5ys= X-Google-Smtp-Source: ABdhPJxDDeLXBL2L2UvXn0iGNApyn0siMgCBDWERYA9ELZbTllGIHrVYT82e0zZP1jLRJxrwQ1MylEe/U2RlPg== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a25:c5c5:: with SMTP id v188mr18044257ybe.121.1631556748642; Mon, 13 Sep 2021 11:12:28 -0700 (PDT) Date: Mon, 13 Sep 2021 11:12:19 -0700 In-Reply-To: <20210913181221.42635-1-chooglen@google.com> Message-Id: <20210913181221.42635-2-chooglen@google.com> Mime-Version: 1.0 References: <20210913181221.42635-1-chooglen@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH 1/3] fsck: verify commit graph when implicitly enabled From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , derrickstolee@github.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org the_repository->settings() is the preferred way to get certain settings (such as "core.commitGraph") because it gets default values from prepare_repo_settings(). However, cmd_fsck() reads the config directly via git_config_get_bool(), which bypasses these default values. This causes fsck to ignore the commit graph if "core.commitgraph" is not explicitly set in the config, even though commit graph is enabled by default. Replace git_config_get_bool("core.commitgraph") in fsck with the equivalent call to the_repository->settings.core_commit_graph. The expected behavior is that fsck respects the config value when it is set, but uses the default value when it is unset. For example, for core.commitGraph, there are three cases: - Config value is set to true -> enabled - Config value is set to false -> disabled - Config value is unset -> enabled As such, tests cover all three cases. Signed-off-by: Glen Choo --- builtin/fsck.c | 3 ++- t/t5318-commit-graph.sh | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 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/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index af88f805aa..48c5096757 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -674,7 +674,7 @@ 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" \ @@ -683,6 +683,27 @@ test_expect_success 'git fsck (checks commit-graph)' ' test_must_fail git 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)' ' + test_when_finished "git config core.commitGraph true" && + + cd "$TRASH_DIRECTORY/full" && + git fsck && + corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \ + "incorrect checksum" && + git config --unset core.commitGraph && + cp commit-graph-pre-write-test $objdir/info/commit-graph && + test_must_fail git fsck +' + test_expect_success 'setup non-the_repository tests' ' rm -rf repo && git init repo && From patchwork Mon Sep 13 18:12:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12490485 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=-26.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 618D0C433EF for ; Mon, 13 Sep 2021 18:12:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49AF5603E8 for ; Mon, 13 Sep 2021 18:12:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347019AbhIMSN4 (ORCPT ); Mon, 13 Sep 2021 14:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346893AbhIMSNt (ORCPT ); Mon, 13 Sep 2021 14:13:49 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E50CC061574 for ; Mon, 13 Sep 2021 11:12:33 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id ib9-20020a0562141c8900b003671c3a1243so56478320qvb.21 for ; Mon, 13 Sep 2021 11:12:33 -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=Hy2fjb6p6+BvE64Mta7TV9v7wszaIBvq4gH9B4CczUI=; b=s1g2se8h29NhY70612yEV+9KkV1KrB7as8FAHP/PaqBVjQ91bezzFmetDq1abGWDq8 /RF33c6066aybCqDvU7Vmg7IiPbkqzsPRr1JJOj8BHVeve1p2HrVgcKbDn3a/NjEqKkD APIzmMqIBkI40UMH5nN9GoF0lzXcoZUz3c1xnmLg83NYsuxWjMxfZjgIck8+4tMTSch1 qpBFiF794Kp6VsUfr14tyFjsrjKHMP+3XICj2sCOxACRledVv4U1FsGqLYwuAFPhbp5K upX/Q3SGc2p7zvQvWj72wDGsOeza/I2d7LmpgRprOesI7GsMaEPtDsGlgJ+8lactGYy2 9TwA== 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=Hy2fjb6p6+BvE64Mta7TV9v7wszaIBvq4gH9B4CczUI=; b=lpbEruhMgCQXqDRlVeiDM7YPK/SEI3IPLhSzFjRVi+yvzgMY/CyjXFO1JIpVCpgLtF UDvH/R8KW26qv3KKP0BKuBYGzkRNdmGVIUIGoCdXvWPAmRiTQ4sxaDFCs2ZXHF+7o0Ra tTXYbIyr1k9qz5D14nN5ygD9jxfV+fH5VWlPoVd5YnwJNogAV3p8u+hFrxg5yEIADuCa K31acqVrDBCpAnr1VRXuzgtXsed/BPArmQJdlIshItn5Wp3HOzewtaEGQlyZfCE3n0CF q+jSwFiRHDJT21R6cDjT4cbPdJP/2YOw/lN+YrysKdxzXowpxfHY3BgKVBYXM2enG8W5 XU1Q== X-Gm-Message-State: AOAM5306sTTohPVda2w8L3ndcszwMdS8c/heX5it/ob7KHLV/UyI3NvA ZcdVX7nqAgH/98JRaQFjYGzS32cIeDMSdfnM2L97kYJW8W2Xted2H1fApVBAdyiLz4H1pQSJelV v2Re1SZVAXr6MjD4LFF1hfD3xiguiQjk3HVNJMrVEBs+7HprG+Lz4OJF0kUiWAFM= X-Google-Smtp-Source: ABdhPJxF0XaE5TmO/e2JK7uQHrztPV71+aD6AOrSaBtQoDFp+UWOG1AkuhlB2x7aRR/2o6bfh/G8H3fa+3GGEA== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a0c:fdc8:: with SMTP id g8mr1026074qvs.12.1631556752732; Mon, 13 Sep 2021 11:12:32 -0700 (PDT) Date: Mon, 13 Sep 2021 11:12:20 -0700 In-Reply-To: <20210913181221.42635-1-chooglen@google.com> Message-Id: <20210913181221.42635-3-chooglen@google.com> Mime-Version: 1.0 References: <20210913181221.42635-1-chooglen@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH 2/3] fsck: verify multi-pack-index when implictly enabled From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , derrickstolee@github.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Like the previous commit, the_repository->settings.core_multi_pack_index is preferable to reading "core.multiPackIndex" from the config because prepare_repo_settings() sets a default value for the_repository->settings. Replace git_config_get_bool("core.multiPackIndex") in fsck with the equivalent call to the_repository->settings.multi_pack_index. Signed-off-by: Glen Choo --- builtin/fsck.c | 2 +- t/t5319-multi-pack-index.sh | 15 ++++++++++++++- 2 files changed, 15 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 3d4d9f10c3..1a17446cf0 100755 --- a/t/t5319-multi-pack-index.sh +++ b/t/t5319-multi-pack-index.sh @@ -404,12 +404,25 @@ test_expect_success 'verify incorrect offset' ' "incorrect object offset" ' -test_expect_success 'git-fsck incorrect offset' ' +test_expect_success 'git-fsck incorrect offset (config set to true)' ' corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \ "incorrect object offset" \ "git -c core.multipackindex=true fsck" ' +test_expect_success 'git-fsck incorrect offset (config set to false)' ' + corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \ + "incorrect object offset" \ + "git -c core.multipackindex=true fsck" && + git -c core.multipackindex=false fsck +' + +test_expect_success 'git-fsck incorrect offset (config unset)' ' + corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \ + "incorrect object offset" \ + "git fsck" +' + test_expect_success 'corrupt MIDX is not reused' ' corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \ "incorrect object offset" && From patchwork Mon Sep 13 18:12:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12490487 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 96DE1C433FE for ; Mon, 13 Sep 2021 18:12:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8299560EE7 for ; Mon, 13 Sep 2021 18:12:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346958AbhIMSN5 (ORCPT ); Mon, 13 Sep 2021 14:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346974AbhIMSNw (ORCPT ); Mon, 13 Sep 2021 14:13:52 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1522DC061768 for ; Mon, 13 Sep 2021 11:12:37 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id e7-20020a056a0000c700b004391956f161so3806269pfj.18 for ; Mon, 13 Sep 2021 11:12:37 -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=uQA0vp52oFr4ibA2LjJ8KV9D7k7RRMdwiHL6mqoRkZg=; b=ljvcUBBi4WjLrz6WAgGQIwhTFuXRB8c5aWZGbYZzW09nIlJ8xXrkJPeLGjyiS/835y 3cZeY1DwNiVy3qZv+uoXOdTqpgioRZC0jRGpJ/k4jn9tBqMSlbCkyzjBpiOXN9iZK80w VBfrpejipX7XwnKCYjAk2gJK6kgxUwimpFGotMu+3VYuDvT2UDEImsFTWCwaetQeFOlv nULNlzuz9k0OGzEInCCHcoxSDil91FOQz7XEMC2dyIbeFNxUymQVDOwwzUncGbanro6v phV1ObfgEuxulfNJpvSMmE4lT242ZoFtHFVvg7GaN94kYs6Wa2COgxfS1VmoZGYoWr/s ae8w== 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=uQA0vp52oFr4ibA2LjJ8KV9D7k7RRMdwiHL6mqoRkZg=; b=1/nChOJdC2qm24+HENF3or7qMmRHaYFD0yu0pTH5sosUrKUlYAKD9MgVFM5At1JPE+ YJ2e/aNbv3WJuRLaT8DliZtzTpEA2L3mXjRkDdt79ahM81KTQau0snZxdW9DMIZQgx2R 4Jy/oWJNuGE1Xvn9SijqWC3GONfoz3oHNZdWGqwPIlFd65eD0KZ1y8ZiQ8WuJ0GRzeCq JV3JeO2OO6QR8b3SYfdulENMxXR5WOKsqSolHhmDqdHC9V5dM7yYyhcUWnv/jI6wA4Cp LLdeNamsGzCABM5yOku2KOojqmMJeKLYdOTo2+Q3cBlC5QINbAt9G2Z4ijmtJ3YrgrQT 1xuQ== X-Gm-Message-State: AOAM531tj0unZ3kbiQ0wn3kCU+Yt4Zt++YWsA+MWH6/7GZZnjb7qh6Ea mjLK/siUtQnY0KEoPhoCNduwaW9/OtAeb5LQIOcDlp19qrfXxDvhr7g84Si4MzxghqfDdMUHPS+ MMvflIaeLxyDLc6McPXdCugQDYTACe+jWn26nwse0lKlW9gxs6FH50o5dIG71dOI= X-Google-Smtp-Source: ABdhPJysvJlkoqDrjKVEoHQe0hNv4sn7UCzLXvHfqSAUyimo23sMnyYUNJqt26X1+pDorXAztD2Q7iz43nKafw== X-Received: from chooglen.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:26d9]) (user=chooglen job=sendgmr) by 2002:a63:b912:: with SMTP id z18mr12221470pge.59.1631556756280; Mon, 13 Sep 2021 11:12:36 -0700 (PDT) Date: Mon, 13 Sep 2021 11:12:21 -0700 In-Reply-To: <20210913181221.42635-1-chooglen@google.com> Message-Id: <20210913181221.42635-4-chooglen@google.com> Mime-Version: 1.0 References: <20210913181221.42635-1-chooglen@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH 3/3] gc: perform incremental repack when implictly enabled From: Glen Choo To: git@vger.kernel.org Cc: Glen Choo , derrickstolee@github.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org builtin/gc.c has two ways of checking of 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_repository->settings.core_multi_pack_index should be preferred because it has default values from prepare_repo_settings(). Standardize on the_repository->settings.core_multi_pack_index to check if multi-pack-index is enabled. Signed-off-by: Glen Choo --- builtin/gc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builtin/gc.c b/builtin/gc.c index f05d2f0a1a..070b7dccb1 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1051,12 +1051,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",