fsck: verify multi-pack-index when implictly enabled

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 <avarab@gmail.com> Signed-off-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Glen Choo committed Oct 15, 2021 at 13:16 UTC dc5570872f684f7c838fe7571225d279243b8700
2 files changed +5 -2
builtin/fsck.c
+1 -1
@@ -925,7 +925,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
925 }
926 }
927
928 - if (!git_config_get_bool("core.multipackindex", &i) && i) {
928 + if (the_repository->settings.core_multi_pack_index) {
929 struct child_process midx_verify = CHILD_PROCESS_INIT;
930 const char *midx_argv[] = { "multi-pack-index", "verify", NULL, NULL, NULL };
931
t/t5319-multi-pack-index.sh
+4 -1
@@ -452,7 +452,10 @@ test_expect_success 'verify incorrect offset' '
452 test_expect_success 'git-fsck incorrect offset' '
453 corrupt_midx_and_verify $MIDX_BYTE_OFFSET "\377" $objdir \
454 "incorrect object offset" \
455 - "git -c core.multipackindex=true fsck"
455 + "git -c core.multiPackIndex=true fsck" &&
456 + test_unconfig core.multiPackIndex &&
457 + test_must_fail git fsck &&
458 + git -c core.multiPackIndex=false fsck
459 '
460
461 test_expect_success 'corrupt MIDX is not reused' '