Re: [PATCH 2/3] fsck: verify multi-pack-index when implictly enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 13, 2021 at 11:12:20AM -0700, Glen Choo wrote:
> 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.

My same suggestion about referencing the first commit for which this
would have been broken applies here, too. In this case, that'd be
18e449f86b (midx: enable core.multiPackIndex by default, 2020-09-25).

> 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 <chooglen@xxxxxxxxxx>
> ---
>  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 };

Good.

> 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
> +'

This test is a little awkward, since it looks like the first command is
the same as the previous test (making it unnecessary). But it turns out
that it *is* necessary, since it sets up the corrupt MIDX (which is
thrown away at the end of each test).

So I would suggest one of two things:

  - Either replace this with a more flexible version of
    corrupt_midx_and_verify that allows the enclosing test to pass. Note
    that this may be awkward, since the whole point is that we want to
    notice the corruption in the first place.

  - Or, (more favorably) combine this all into a single test, like so:

        corrupt_midx_and_verify "$MIDX_BYTE_OFFSET" "\377" $objdir \
          "incorrect object offset" \
          "git fsck" &&
        test_must_fail git -c core.multiPackIndex=true fsck &&
        git -c core.multiPackIndex=false fsck

Which does all of the setup for the three tests at once, and then
specifies each behavior individually.

Thanks,
Taylor



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux