All of lore.kernel.org
 help / color / mirror / Atom feed
From: Toon Claes <toon@iotcl.com>
To: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Cc: Karthik Nayak <karthik.188@gmail.com>
Subject: Re: [PATCH v2 05/10] odb: provide infrastructure for pluggable fsck checks
Date: Fri, 11 Sep 2026 13:14:03 +0200	[thread overview]
Message-ID: <87a4ponipw.fsf@emacs.iotcl.com> (raw)
In-Reply-To: <20260831-pks-odb-source-fsck-v2-5-f9b16ef4957b@pks.im>

Patrick Steinhardt <ps@pks.im> writes:

> The on-disk consistency checks in git-fsck(1) are conceptually
> backend-specific: while connectivity checks and object-level parsing
> checks are generic, verifying the physical integrity of packfiles and
> loose objects is meaningful only to backends that use these formats:
> Having these checks live in "builtin/fsck.c" violates that layering,
> because it forces the command to reach directly into format-specific
> internals.
>
> Provide new infrastructure to make these format-specific checks
> pluggable and implement stubs for the different source types we already
> have. In subsequent commits we'll move functionality over piece by
> piece.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  builtin/fsck.c        | 16 +++++++++++-----
>  odb.c                 |  9 +++++++++
>  odb.h                 | 23 +++++++++++++++++++++++
>  odb/source-files.c    | 13 +++++++++++++
>  odb/source-inmemory.c |  8 ++++++++
>  odb/source-loose.c    |  7 +++++++
>  odb/source-packed.c   |  8 ++++++++
>  odb/source.h          | 21 +++++++++++++++++++++
>  8 files changed, 100 insertions(+), 5 deletions(-)
>
> diff --git a/builtin/fsck.c b/builtin/fsck.c
> index 3f6056535f..adbe192e56 100644
> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -965,7 +965,9 @@ int cmd_fsck(int argc,
>  	     const char *prefix,
>  	     struct repository *repo)
>  {
> -	int check_full = 1;
> +	struct odb_fsck_options odb_fsck_opts = {
> +		.flags = ODB_FSCK_FULL,
> +	};
>  	int keep_cache_objects = 0;
>  	int name_objects = 0;
>  	int check_references = 1;
> @@ -977,7 +979,8 @@ int cmd_fsck(int argc,
>  		OPT_BOOL(0, "root", &show_root, N_("report root nodes")),
>  		OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")),
>  		OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")),
> -		OPT_BOOL(0, "full", &check_full, N_("also consider packs and alternate objects")),
> +		OPT_BIT(0, "full", &odb_fsck_opts.flags,
> +			N_("also consider packs and alternate objects"), ODB_FSCK_FULL),
>  		OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")),
>  		OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")),
>  		OPT_BOOL(0, "lost-found", &write_lost_and_found,
> @@ -1018,7 +1021,7 @@ int cmd_fsck(int argc,
>  		show_progress = 0;
>  
>  	if (write_lost_and_found) {
> -		check_full = 1;
> +		odb_fsck_opts.flags |= ODB_FSCK_FULL;
>  		include_reflogs = 0;
>  	}
>  
> @@ -1047,10 +1050,13 @@ int cmd_fsck(int argc,
>  				    mark_object_for_connectivity, repo, 0);
>  	} else {
>  		for (source = repo->objects->sources; source; source = source->next)
> -			if (check_full || source->local)
> +			if ((odb_fsck_opts.flags & ODB_FSCK_FULL) || source->local)
>  				fsck_source(repo, source);
>  
> -		if (check_full) {
> +		if (odb_fsck(repo->objects, &odb_fsck_opts) < 0)
> +			errors_found |= ERROR_OBJECT;
> +
> +		if (odb_fsck_opts.flags & ODB_FSCK_FULL) {
>  			struct packed_git *p;
>  			uint32_t total = 0, count = 0;
>  			struct progress *progress = NULL;
> diff --git a/odb.c b/odb.c
> index 1fe20808eb..766043b685 100644
> --- a/odb.c
> +++ b/odb.c
> @@ -1177,3 +1177,12 @@ void odb_reprepare(struct object_database *o)
>  {
>  	odb_prepare(o, ODB_PREPARE_FLUSH_CACHES);
>  }
> +
> +int odb_fsck(struct object_database *odb, struct odb_fsck_options *options)
> +{
> +	int ret = 0;
> +	for (struct odb_source *source = odb->sources; source; source = source->next)
> +		if ((options->flags & ODB_FSCK_FULL) || source->local)
> +			ret |= odb_source_fsck(source, options);

Shouldn't it be the responsibility of the source to determine whether it
should be included due to the `--full` flag? In the future there might
be other types of sources which have possibly a different meaning for
"local". So would it make sense to have them check for ODB_FSCK_FULL
themselves.

-- 
Laters,
Toon

  reply	other threads:[~2026-09-11 11:14 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 14:30 [PATCH 00/10] odb: make consistency checks pluggable Patrick Steinhardt
2026-08-25 14:30 ` [PATCH 01/10] builtin/fsck: use `fsck_obj_buffer()` when checking loose objects Patrick Steinhardt
2026-08-27 10:00   ` Karthik Nayak
2026-08-31  6:00     ` Patrick Steinhardt
2026-08-25 14:30 ` [PATCH 02/10] builtin/fsck: merge `fsck_obj_buffer()` and `fsck_obj()` Patrick Steinhardt
2026-08-27 10:03   ` Karthik Nayak
2026-08-31  6:00     ` Patrick Steinhardt
2026-08-25 14:30 ` [PATCH 03/10] builtin/fsck: de-globalize option handling Patrick Steinhardt
2026-08-27 10:05   ` Karthik Nayak
2026-08-25 14:30 ` [PATCH 04/10] builtin/fsck: don't check alternates with "--no-full" Patrick Steinhardt
2026-08-27 10:12   ` Karthik Nayak
2026-08-31  6:00     ` Patrick Steinhardt
2026-08-25 14:30 ` [PATCH 05/10] odb: provide infrastructure for pluggable fsck checks Patrick Steinhardt
2026-08-27 10:49   ` Karthik Nayak
2026-08-31  6:00     ` Patrick Steinhardt
2026-08-25 14:30 ` [PATCH 06/10] builtin/fsck: move packfile verification into the packed source Patrick Steinhardt
2026-08-25 14:30 ` [PATCH 07/10] builtin/fsck: move reverse index " Patrick Steinhardt
2026-08-25 14:30 ` [PATCH 08/10] builtin/fsck: move bitmap " Patrick Steinhardt
2026-08-27 10:54   ` Karthik Nayak
2026-08-31  6:00     ` Patrick Steinhardt
2026-08-31  9:26       ` Karthik Nayak
2026-08-25 14:30 ` [PATCH 09/10] builtin/fsck: move multi-pack index " Patrick Steinhardt
2026-08-25 14:30 ` [PATCH 10/10] builtin/fsck: move loose object verification into the loose source Patrick Steinhardt
2026-08-27 10:58 ` [PATCH 00/10] odb: make consistency checks pluggable Karthik Nayak
2026-08-31  6:46 ` [PATCH v2 " Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 01/10] builtin/fsck: use `fsck_obj_buffer()` when checking loose objects Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 02/10] builtin/fsck: merge `fsck_obj_buffer()` and `fsck_obj()` Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 03/10] builtin/fsck: de-globalize option handling Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 04/10] builtin/fsck: don't check alternates with "--no-full" Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 05/10] odb: provide infrastructure for pluggable fsck checks Patrick Steinhardt
2026-09-11 11:14     ` Toon Claes [this message]
2026-09-11 12:23       ` Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 06/10] builtin/fsck: move packfile verification into the packed source Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 07/10] builtin/fsck: move reverse index " Patrick Steinhardt
2026-09-11 11:14     ` Toon Claes
2026-08-31  6:46   ` [PATCH v2 08/10] builtin/fsck: move bitmap " Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 09/10] builtin/fsck: move multi-pack index " Patrick Steinhardt
2026-09-11 11:14     ` Toon Claes
2026-09-11 12:23       ` Patrick Steinhardt
2026-08-31  6:46   ` [PATCH v2 10/10] builtin/fsck: move loose object verification into the loose source Patrick Steinhardt
2026-09-11 11:15     ` Toon Claes
2026-09-11 12:23       ` Patrick Steinhardt
2026-08-31  9:26   ` [PATCH v2 00/10] odb: make consistency checks pluggable Karthik Nayak
2026-09-11 13:27 ` [PATCH v3 " Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 01/10] builtin/fsck: use `fsck_obj_buffer()` when checking loose objects Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 02/10] builtin/fsck: merge `fsck_obj_buffer()` and `fsck_obj()` Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 03/10] builtin/fsck: de-globalize option handling Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 04/10] builtin/fsck: don't check alternates with "--no-full" Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 05/10] odb: provide infrastructure for pluggable fsck checks Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 06/10] builtin/fsck: move packfile verification into the packed source Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 07/10] builtin/fsck: move reverse index " Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 08/10] builtin/fsck: move bitmap " Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 09/10] builtin/fsck: move multi-pack index " Patrick Steinhardt
2026-09-11 13:27   ` [PATCH v3 10/10] builtin/fsck: move loose object verification into the loose source 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=87a4ponipw.fsf@emacs.iotcl.com \
    --to=toon@iotcl.com \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.