From: Eric Sunshine <sunshine@sunshineco.com>
To: Glen Choo <chooglen@google.com>, git@vger.kernel.org
Cc: Taylor Blau <me@ttaylorr.com>
Subject: Re: [PATCH v2 1/3] fsck: verify commit graph when implicitly enabled
Date: Wed, 29 Sep 2021 02:09:23 -0400 [thread overview]
Message-ID: <e1447d0e-091d-c659-b702-c5b33fffdb59@sunshineco.com> (raw)
In-Reply-To: <20210917225459.68086-2-chooglen@google.com>
On 9/17/21 6:54 PM, Glen Choo wrote:
> 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. This worked fine until commit-graph was
> enabled by default in 31b1de6a09 (commit-graph: turn on commit-graph by
> default, 2019-08-13).
>
> Replace git_config_get_bool("core.commitgraph") in fsck with the
> equivalent call to the_repository->settings.core_commit_graph.
> [...]
> Signed-off-by: Glen Choo <chooglen@google.com>
> ---
> diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
> @@ -674,7 +674,7 @@ test_expect_success 'detect incorrect chunk count' '
> -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,28 @@ test_expect_success 'git fsck (checks commit-graph)' '
> test_must_fail git fsck
> '
Because I took the time to scan backward through this test script, I
understand that `core.commitGraph` is already `true` by the time this
test is reached, thus the new test title is accurate (for now). However,
it would be a bit easier to reason about this and make it more robust by
having the test itself guarantee that it is set to `true` by invoking
`git config core.commitGraph true`.
> +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 &&
> + test_config core.commitGraph false &&
> + git fsck
> +'
test_config() unsets the config variable when the test completes, so I'm
wondering if its use is in fact desirable here. I ask because, from a
quick scan through the file, it appears that many tests in this script
assume that `core.commitGraph` is `true`, so it's not clear that
unsetting it at the end of this test is a good idea in general.
> +test_expect_success 'git fsck (checks commit-graph when config unset)' '
> + test_when_finished "git config core.commitGraph true" &&
> +
> + cd "$TRASH_DIRECTORY/full" &&
I find it somewhat confusing to reason about the behavior of
test_when_finished() when it is invoked like this before the `cd`. It's
true that the end-of-test `git config core.commitGraph true` will be
invoked within `full` as desired (except in the very unusual case of the
`cd` failing), so it's probably correct, but it requires extra thought
to come to that conclusion. Switching the order of these two lines might
lower the cognitive load a bit.
> + git fsck &&
> + corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
> + "incorrect checksum" &&
> + test_unconfig core.commitGraph &&
> + cp commit-graph-pre-write-test $objdir/info/commit-graph &&
> + test_must_fail git fsck
> +'
Taking Taylor's comment[1] on v1 patch [2/3] into account, I wonder if
it would be simpler for these all to be combined into a single test.
Something like (untested):
cd "$TRASH_DIRECTORY/full" &&
test_when_finished "git config core.commitGraph true" &&
git config core.commitGraph true &&
git fsck &&
corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
"incorrect checksum" &&
cp commit-graph-pre-write-test $objdir/info/commit-graph &&
test_must_fail git fsck &&
git config core.commitGraph false &&
git fsck &&
git config --unset-all core.commitGraph &&
test_must_fail git fsck
I didn't bother using test_unconfig() since, in this case, we _know_
that the config variable is set, thus don't have to worry about `git
config --unset-all` failing.
A downside of combining the tests like this is that it makes it a bit
more cumbersome to diagnose a failure (because there is more code and
more cases to wade through).
Anyhow, I don't have a strong feeling one way or the other about
combining the test or leaving them separate.
[1]: https://lore.kernel.org/git/YT+n81yGPYEiMXwQ@nand.local/
next prev parent reply other threads:[~2021-09-29 6:09 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 18:12 [PATCH 0/3] Use default values from settings instead of config Glen Choo
2021-09-13 18:12 ` [PATCH 1/3] fsck: verify commit graph when implicitly enabled Glen Choo
2021-09-13 19:29 ` Taylor Blau
2021-09-13 19:33 ` Eric Sunshine
2021-09-13 19:36 ` Taylor Blau
2021-09-13 23:15 ` Glen Choo
2021-09-13 23:32 ` Eric Sunshine
2021-09-14 1:09 ` Taylor Blau
2021-09-14 2:05 ` Eric Sunshine
2021-09-14 1:07 ` Taylor Blau
2021-09-13 18:12 ` [PATCH 2/3] fsck: verify multi-pack-index when implictly enabled Glen Choo
2021-09-13 19:35 ` Taylor Blau
2021-09-13 18:12 ` [PATCH 3/3] gc: perform incremental repack " Glen Choo
2021-09-13 19:37 ` Taylor Blau
2021-09-14 17:41 ` Glen Choo
2021-09-14 4:00 ` Bagas Sanjaya
2021-09-16 17:15 ` Glen Choo
2021-09-13 19:19 ` [PATCH 0/3] Use default values from settings instead of config Taylor Blau
2021-09-17 22:54 ` [PATCH v2 " Glen Choo
2021-09-17 22:54 ` [PATCH v2 1/3] fsck: verify commit graph when implicitly enabled Glen Choo
2021-09-29 6:09 ` Eric Sunshine [this message]
2021-09-30 18:00 ` Glen Choo
2021-09-30 18:35 ` Glen Choo
2021-09-30 18:39 ` Eric Sunshine
2021-10-01 17:28 ` Glen Choo
2021-09-17 22:54 ` [PATCH v2 2/3] fsck: verify multi-pack-index when implictly enabled Glen Choo
2021-09-29 6:20 ` Eric Sunshine
2021-09-29 22:56 ` Glen Choo
2021-09-17 22:54 ` [PATCH v2 3/3] gc: perform incremental repack " Glen Choo
2021-09-29 6:39 ` Eric Sunshine
2021-09-27 17:59 ` [PATCH v2 0/3] Use default values from settings instead of config Glen Choo
2021-09-29 6:43 ` Eric Sunshine
2021-09-29 22:53 ` Glen Choo
2021-10-05 0:19 ` [PATCH v3 " Glen Choo
2021-10-05 0:19 ` [PATCH v3 1/3] fsck: verify commit graph when implicitly enabled Glen Choo
2021-10-05 0:19 ` [PATCH v3 2/3] fsck: verify multi-pack-index when implictly enabled Glen Choo
2021-10-05 0:19 ` [PATCH v3 3/3] gc: perform incremental repack " Glen Choo
2021-10-05 11:57 ` [PATCH v3 0/3] Use default values from settings instead of config Ævar Arnfjörð Bjarmason
2021-10-05 17:43 ` Derrick Stolee
2021-10-05 19:10 ` Ævar Arnfjörð Bjarmason
2021-10-05 22:25 ` Glen Choo
2021-10-09 7:24 ` Junio C Hamano
2021-10-11 19:58 ` Glen Choo
2021-10-11 20:08 ` Junio C Hamano
2021-10-11 20:48 ` Glen Choo
2021-10-12 17:42 ` [PATCH v4 " Glen Choo
2021-10-12 17:42 ` [PATCH v4 1/3] fsck: verify commit graph when implicitly enabled Glen Choo
2021-10-12 17:42 ` [PATCH v4 2/3] fsck: verify multi-pack-index when implictly enabled Glen Choo
2021-10-12 17:42 ` [PATCH v4 3/3] gc: perform incremental repack " Glen Choo
2021-10-12 20:23 ` [PATCH v4 0/3] Use default values from settings instead of config Junio C Hamano
2021-10-12 20:34 ` Ævar Arnfjörð Bjarmason
2021-10-12 22:29 ` Glen Choo
2021-10-14 15:53 ` Ævar Arnfjörð Bjarmason
2021-10-13 13:12 ` Derrick Stolee
2021-10-13 15:57 ` Ævar Arnfjörð Bjarmason
2021-10-14 16:53 ` Derrick Stolee
2021-10-14 22:21 ` Glen Choo
2021-10-14 23:38 ` Ævar Arnfjörð Bjarmason
2021-10-14 22:25 ` Junio C Hamano
2021-10-15 15:57 ` Junio C Hamano
2021-10-15 20:16 ` [PATCH v5 " Glen Choo
2021-10-15 20:16 ` [PATCH v5 1/3] fsck: verify commit graph when implicitly enabled Glen Choo
2021-10-15 20:16 ` [PATCH v5 2/3] fsck: verify multi-pack-index when implictly enabled Glen Choo
2021-10-15 20:16 ` [PATCH v5 3/3] gc: perform incremental repack " Glen Choo
2021-10-15 21:31 ` [PATCH v5 0/3] Use default values from settings instead of config Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1447d0e-091d-c659-b702-c5b33fffdb59@sunshineco.com \
--to=sunshine@sunshineco.com \
--cc=chooglen@google.com \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).