git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Taylor Blau <me@ttaylorr.com>
Date
Sep 13, 2021, 19:35 UTC
Message-ID
<YT+n81yGPYEiMXwQ@nand.local>
In-Reply-To
<20210913181221.42635-3-chooglen@google.com>
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).

Show 21 quoted lines
> 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@google.com>
> ---
>  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.
Show 21 quoted lines
> 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

Previous: Glen ChooNext: Glen Choo
Message 12 of 65 in “Use default values from settings instead of config”
  1. 0/3 Use default values from settings instead of configGlen Choo, Sep 13, 2021
  2. 1/3 fsck: verify commit graph when implicitly enabledGlen Choo, Sep 13, 2021
  3. Taylor BlauSep 13, 2021
  4. Eric SunshineSep 13, 2021
  5. Taylor BlauSep 13, 2021
  6. Glen ChooSep 13, 2021
  7. Eric SunshineSep 13, 2021
  8. Taylor BlauSep 14, 2021
  9. Eric SunshineSep 14, 2021
  10. Taylor BlauSep 14, 2021
  11. 2/3 fsck: verify multi-pack-index when implictly enabledGlen Choo, Sep 13, 2021
  12. Taylor BlauSep 13, 2021
  13. 3/3 gc: perform incremental repack when implictly enabledGlen Choo, Sep 13, 2021
  14. Taylor BlauSep 13, 2021
  15. Glen ChooSep 14, 2021
  16. Bagas SanjayaSep 14, 2021
  17. Glen ChooSep 16, 2021
  18. Taylor BlauSep 13, 2021
  19. 0/3 Use default values from settings instead of configGlen Choo, Sep 17, 2021
  20. 1/3 fsck: verify commit graph when implicitly enabledGlen Choo, Sep 17, 2021
  21. Eric SunshineSep 29, 2021
  22. Glen ChooSep 30, 2021
  23. Glen ChooSep 30, 2021
  24. Eric SunshineSep 30, 2021
  25. Glen ChooOct 1, 2021
  26. 2/3 fsck: verify multi-pack-index when implictly enabledGlen Choo, Sep 17, 2021
  27. Eric SunshineSep 29, 2021
  28. Glen ChooSep 29, 2021
  29. 3/3 gc: perform incremental repack when implictly enabledGlen Choo, Sep 17, 2021
  30. Eric SunshineSep 29, 2021
  31. Glen ChooSep 27, 2021
  32. Eric SunshineSep 29, 2021
  33. Glen ChooSep 29, 2021
  34. 0/3 Use default values from settings instead of configGlen Choo, Oct 5, 2021
  35. 1/3 fsck: verify commit graph when implicitly enabledGlen Choo, Oct 5, 2021
  36. 2/3 fsck: verify multi-pack-index when implictly enabledGlen Choo, Oct 5, 2021
  37. 3/3 gc: perform incremental repack when implictly enabledGlen Choo, Oct 5, 2021
  38. Ævar Arnfjörð BjarmasonOct 5, 2021
  39. Derrick StoleeOct 5, 2021
  40. Ævar Arnfjörð BjarmasonOct 5, 2021
  41. Glen ChooOct 5, 2021
  42. Junio C HamanoOct 9, 2021
  43. Glen ChooOct 11, 2021
  44. Junio C HamanoOct 11, 2021
  45. Glen ChooOct 11, 2021
  46. 0/3 Use default values from settings instead of configGlen Choo, Oct 12, 2021
  47. 1/3 fsck: verify commit graph when implicitly enabledGlen Choo, Oct 12, 2021
  48. 2/3 fsck: verify multi-pack-index when implictly enabledGlen Choo, Oct 12, 2021
  49. 3/3 gc: perform incremental repack when implictly enabledGlen Choo, Oct 12, 2021
  50. Junio C HamanoOct 12, 2021
  51. Ævar Arnfjörð BjarmasonOct 12, 2021
  52. Glen ChooOct 12, 2021
  53. Ævar Arnfjörð BjarmasonOct 14, 2021
  54. Derrick StoleeOct 13, 2021
  55. Ævar Arnfjörð BjarmasonOct 13, 2021
  56. Derrick StoleeOct 14, 2021
  57. Glen ChooOct 14, 2021
  58. Ævar Arnfjörð BjarmasonOct 14, 2021
  59. Junio C HamanoOct 14, 2021
  60. Junio C HamanoOct 15, 2021
  61. 0/3 Use default values from settings instead of configGlen Choo, Oct 15, 2021
  62. 1/3 fsck: verify commit graph when implicitly enabledGlen Choo, Oct 15, 2021
  63. 2/3 fsck: verify multi-pack-index when implictly enabledGlen Choo, Oct 15, 2021
  64. 3/3 gc: perform incremental repack when implictly enabledGlen Choo, Oct 15, 2021
  65. Junio C HamanoOct 15, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.