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

Re: [PATCH 1/3] fsck: verify commit graph when implicitly enabled

From
Taylor Blau <me@ttaylorr.com>
Date
Sep 13, 2021, 19:29 UTC
Message-ID
<YT+mlW851sRyt842@nand.local>
In-Reply-To
<20210913181221.42635-2-chooglen@google.com>
On Mon, Sep 13, 2021 at 11:12:19AM -0700, Glen Choo wrote:
Show 7 quoted lines
> 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.

Small nit; "the_repository->settings()" should be spelled as "the_repository->settings", since "settings" is not a function.

It may be worth noting that this was totally fine before core.commitGraph's default changed to true. That happened in 31b1de6a09 (commit-graph: turn on commit-graph by default, 2019-08-13), which is the first time this sort of regression would have appeared.

Show 10 quoted lines
>  	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 };

Here's the main part of your change, which is obviously correct (I'm glossing over the earlier part where you call prepare_repo_settings(); also required and obviously correct).

Show 7 quoted lines
> +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

Nit; I recommend replacing the `-c` style configuration with `test_config`, which modifies `$GIT_DIR/config` but only for the duration of the sub-shell.

> +'
> +
> +test_expect_success 'git fsck (checks commit-graph when config unset)' '
> +	test_when_finished "git config core.commitGraph true" &&

... which would allow you to get rid of something like this (since you can avoid modifying the state visible outside of this test).

Show 5 quoted lines
> +	cd "$TRASH_DIRECTORY/full" &&
> +	git fsck &&
> +	corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
> +		"incorrect checksum" &&
> +        git config --unset core.commitGraph &&

But I'm not aware of a way to temporarily unset a configuration variable for the duration of a test, so here I would probably write:

    test_must_fail git -c core.commitGraph= fsck
which Git interprets as "pretend this variable is unset in-core".

Thanks, Taylor

Previous: Glen ChooNext: Eric Sunshine
Message 3 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.