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 09/10] builtin/fsck: move multi-pack index verification into the packed source
Date: Fri, 11 Sep 2026 13:14:44 +0200 [thread overview]
Message-ID: <877bksnior.fsf@emacs.iotcl.com> (raw)
In-Reply-To: <20260831-pks-odb-source-fsck-v2-9-f9b16ef4957b@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> The checks for multi-pack indexes are hosted in `cmd_fsck()` directly.
> These checks are obviously specific to the "packed" backend.
>
> Move the logic into `odb_source_packed_fsck()`. As in preceding commits,
> this means that we now properly honor both "--connectivity-only" and
> "--no-full". Furthermore, we drop the dedicated `ERROR_MULTI_PACK_INDEX`
> bit and instead use the generic `ERROR_OBJECT` bit.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> builtin/fsck.c | 18 ------------------
> odb/source-packed.c | 27 +++++++++++++++++++++++++++
> t/t5319-multi-pack-index.sh | 13 +++++++++++++
> 3 files changed, 40 insertions(+), 18 deletions(-)
>
> diff --git a/builtin/fsck.c b/builtin/fsck.c
> index 2f7d29aa56..7eaea340b0 100644
> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -48,7 +48,6 @@ static timestamp_t now;
> #define ERROR_REACHABLE 02
> #define ERROR_REFS 010
> #define ERROR_COMMIT_GRAPH 020
> -#define ERROR_MULTI_PACK_INDEX 040
>
> static const char *describe_object(const struct object_id *oid)
> {
> @@ -1085,23 +1084,6 @@ int cmd_fsck(int argc,
> }
> }
>
> - if (repo->settings.core_multi_pack_index) {
> - struct child_process midx_verify = CHILD_PROCESS_INIT;
> -
> - for (source = repo->objects->sources; source; source = source->next) {
> - child_process_init(&midx_verify);
> - midx_verify.git_cmd = 1;
> - strvec_pushl(&midx_verify.args, "multi-pack-index",
> - "verify", "--object-dir", source->path, NULL);
> - if (show_progress)
> - strvec_push(&midx_verify.args, "--progress");
> - else
> - strvec_push(&midx_verify.args, "--no-progress");
> - if (run_command(&midx_verify))
> - errors_found |= ERROR_MULTI_PACK_INDEX;
> - }
> - }
> -
> free_snapshot_refs(&snap);
> return errors_found;
> }
> diff --git a/odb/source-packed.c b/odb/source-packed.c
> index 2b5dc502f5..9f42552377 100644
> --- a/odb/source-packed.c
> +++ b/odb/source-packed.c
> @@ -14,6 +14,7 @@
> #include "packfile.h"
> #include "pack-bitmap.h"
> #include "progress.h"
> +#include "run-command.h"
>
> static int find_pack_entry(struct odb_source_packed *store,
> const struct object_id *oid,
> @@ -897,6 +898,29 @@ static int verify_reverse_indices(struct odb_source_packed *source,
> return res;
> }
>
> +static int verify_midx(struct odb_source_packed *source,
> + struct odb_fsck_options *opts)
> +{
> + struct child_process midx_verify = CHILD_PROCESS_INIT;
> + int ret = 0;
I don't see much reason to use a `ret` value instead of using early
returns instead.
> +
> + if (!source->base.odb->repo->settings.core_multi_pack_index)
Because we cannot ensure where this function was called from, shall we
BUG() if (!settings.initialized)?
> + return 0;
> +
> + child_process_init(&midx_verify);
> + midx_verify.git_cmd = 1;
> + strvec_pushl(&midx_verify.args, "multi-pack-index",
> + "verify", "--object-dir", source->base.path, NULL);
> + if (opts->flags & ODB_FSCK_PROGRESS)
> + strvec_push(&midx_verify.args, "--progress");
> + else
> + strvec_push(&midx_verify.args, "--no-progress");
> + if (run_command(&midx_verify))
> + ret = -1;
> +
> + return ret;
> +}
> +
> static int odb_source_packed_fsck(struct odb_source *source,
> struct odb_fsck_options *opts)
> {
> @@ -912,6 +936,9 @@ static int odb_source_packed_fsck(struct odb_source *source,
> if (verify_bitmap_files(packed))
> ret = -1;
>
> + if (verify_midx(packed, opts) < 0)
Any reason why you're checking negative value here and not in the if
above?
> + ret = -1;
> +
> return ret;
> }
>
> diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh
> index 68143cb5b7..20b010c33b 100755
> --- a/t/t5319-multi-pack-index.sh
> +++ b/t/t5319-multi-pack-index.sh
> @@ -573,6 +573,19 @@ test_expect_success 'verify incorrect checksum' '
> $objdir "incorrect checksum"
> '
>
> +test_expect_success 'git fsck --no-full checks multi-pack-index, --connectivity-only does not' '
> + pos=$(($(wc -c <$objdir/pack/multi-pack-index) - 10)) &&
> + corrupt_midx_and_verify $pos \
> + "\377\377\377\377\377\377\377\377\377\377" \
> + $objdir "incorrect checksum" &&
> +
> + test_must_fail git fsck --no-full 2>err &&
> + test_grep "incorrect checksum" err &&
> +
> + git fsck --connectivity-only 2>err &&
> + test_grep ! "incorrect checksum" err
> +'
> +
> test_expect_success 'setup for v1-specific fsck tests' '
> git -c midx.version=1 multi-pack-index write
> '
>
> --
> 2.55.0.979.g7e5102b832.dirty
>
>
--
Laters,
Toon
next prev parent 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
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 [this message]
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=877bksnior.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox