From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 01/12] fetch-pack: move fsck options into function scope
Date: Mon, 23 Mar 2026 08:43:51 -0700 [thread overview]
Message-ID: <xmqqv7em5z60.fsf@gitster.g> (raw)
In-Reply-To: <20260323-b4-pks-fsck-without-the-repository-v2-1-e8dc79bca651@pks.im> (Patrick Steinhardt's message of "Mon, 23 Mar 2026 16:02:52 +0100")
Patrick Steinhardt <ps@pks.im> writes:
> When fetching a packfile, we optionally verify received objects via the
> fsck subsystem. The options for those consistency checks are declared in
> global scope without a good reason, and they are never cleaned up. So in
> case the options are reused, they may accumulate more state over time.
Great realization.
So we have two code paths (the original and v2), both of which used
to use the one in the global scope without cleaning up, but now we
have a way to proerly clean them up. Very nice.
> Furthermore, in subsequent changes we'll introduce a repository pointer
> into the structure. Obviously though, we don't have a repository
> available at static time, except for `the_repository`, which we don't
> want to use here.
>
> Refactor the code to move the options into the respective functions and
> properly manage their lifecycle.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> fetch-pack.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fetch-pack.c b/fetch-pack.c
> index 6ecd468ef7..ec5abb92b5 100644
> --- a/fetch-pack.c
> +++ b/fetch-pack.c
> @@ -51,7 +51,6 @@ static int server_supports_filtering;
> static int advertise_sid;
> static struct shallow_lock shallow_lock;
> static const char *alternate_shallow_file;
> -static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
> static struct strbuf fsck_msg_types = STRBUF_INIT;
> static struct string_list uri_protocols = STRING_LIST_INIT_DUP;
>
> @@ -1100,6 +1099,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
> struct shallow_info *si,
> struct string_list *pack_lockfiles)
> {
> + struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
> struct repository *r = the_repository;
> struct ref *ref = copy_ref_list(orig_ref);
> struct object_id oid;
> @@ -1235,6 +1235,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
> die("fsck failed");
>
> all_done:
> + fsck_options_clear(&fsck_options);
> if (negotiator)
> negotiator->release(negotiator);
> return ref;
> @@ -1654,6 +1655,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
> struct string_list *pack_lockfiles)
> {
> struct repository *r = the_repository;
> + struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES;
> struct ref *ref = copy_ref_list(orig_ref);
> enum fetch_state state = FETCH_CHECK_LOCAL;
> struct oidset common = OIDSET_INIT;
> @@ -1882,6 +1884,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
> if (negotiator)
> negotiator->release(negotiator);
>
> + fsck_options_clear(&fsck_options);
> oidset_clear(&common);
> return ref;
> }
next prev parent reply other threads:[~2026-03-23 15:43 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 11:47 [PATCH 00/14] fsck: drop use of `the_repository` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 01/14] fsck: drop `the_repository` in `fsck_walk()` Patrick Steinhardt
2026-03-20 23:09 ` Junio C Hamano
2026-03-23 12:22 ` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 02/14] fsck: drop `the_repository` in `fsck_finish()` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 03/14] fsck: refactor interface to parse fsck options Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 04/14] fsck: drop `the_repository` in `fsck_set_msg_types()` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 05/14] fsck: stop relying on global state via `parse_oid_hex()` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 06/14] builtin/fsck: fix trivial dependence on `the_repository` Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 07/14] builtin/fsck: stop using `the_repository` when snapshotting refs Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 08/14] builtin/fsck: stop using `the_repository` when checking refs Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 09/14] builtin/fsck: stop using `the_repository` when checking reflogs Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 10/14] builtin/fsck: stop using `the_repository` with loose objects Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 11/14] builtin/fsck: stop using `the_repository` when checking packed objects Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 12/14] builtin/fsck: stop using `the_repository` when marking objects Patrick Steinhardt
2026-03-20 11:47 ` [PATCH 13/14] fsck: provide repository in `struct fsck_report_object` Patrick Steinhardt
2026-03-20 23:13 ` Junio C Hamano
2026-03-20 11:47 ` [PATCH 14/14] builtin/fsck: stop using `the_repository` in error reporting Patrick Steinhardt
2026-03-23 15:02 ` [PATCH v2 00/12] fsck: drop use of `the_repository` Patrick Steinhardt
2026-03-23 15:02 ` [PATCH v2 01/12] fetch-pack: move fsck options into function scope Patrick Steinhardt
2026-03-23 15:43 ` Junio C Hamano [this message]
2026-03-23 15:02 ` [PATCH v2 02/12] fsck: initialize fsck options via a function Patrick Steinhardt
2026-03-23 15:48 ` Junio C Hamano
2026-03-23 15:02 ` [PATCH v2 03/12] fsck: store repository in fsck options Patrick Steinhardt
2026-03-23 15:02 ` [PATCH v2 04/12] fsck: drop USE_THE_REPOSITORY Patrick Steinhardt
2026-03-23 15:02 ` [PATCH v2 05/12] builtin/fsck: fix trivial dependence on `the_repository` Patrick Steinhardt
2026-03-23 15:02 ` [PATCH v2 06/12] builtin/fsck: stop using `the_repository` when snapshotting refs Patrick Steinhardt
2026-03-23 15:02 ` [PATCH v2 07/12] builtin/fsck: stop using `the_repository` when checking refs Patrick Steinhardt
2026-03-23 15:02 ` [PATCH v2 08/12] builtin/fsck: stop using `the_repository` when checking reflogs Patrick Steinhardt
2026-03-23 15:03 ` [PATCH v2 09/12] builtin/fsck: stop using `the_repository` with loose objects Patrick Steinhardt
2026-03-23 15:03 ` [PATCH v2 10/12] builtin/fsck: stop using `the_repository` when checking packed objects Patrick Steinhardt
2026-03-23 15:03 ` [PATCH v2 11/12] builtin/fsck: stop using `the_repository` when marking objects Patrick Steinhardt
2026-03-23 15:03 ` [PATCH v2 12/12] builtin/fsck: stop using `the_repository` in error reporting Patrick Steinhardt
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqv7em5z60.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox