From: Junio C Hamano <gitster@pobox.com>
To: Adrian Ratiu <adrian.ratiu@collabora.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
"Eric W . Biederman" <ebiederm@xmission.com>,
"brian m . carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH v3 1/4] setup: reject compatObjectFormat == objectFormat
Date: Sun, 06 Dec 2026 09:38:55 +0900 [thread overview]
Message-ID: <xmqq33sbi6ow.fsf@gitster.g> (raw)
In-Reply-To: <f74a0fd67af600f45bdb7560253c747aab073c65.1795455594.git.adrian.ratiu@collabora.com> (Adrian Ratiu's message of "Mon, 30 Nov 2026 15:43:22 +0200")
Adrian Ratiu <adrian.ratiu@collabora.com> writes:
> When extensions.compatObjectFormat sets the same hash as the repo
> object format, every command in a build with Rust aborts with:
>
> BUG: repository.c:204: hash_algo and compat_hash_algo match
>
> This includes "git config", so the bad value can't be removed with
> Git. It also happens with no extensions.objectFormat at all, when
> compatObjectFormat is set to the default object format.
Running "git config" inside such a repository triggers gentle setup via
setup_git_directory_gently() and read_and_verify_repository_format().
Because verify_repository_format() previously accepted matching
values, setup proceeded into apply_repository_format() and crashed
in repo_set_compat_hash_algo() before "git config" could even treat
the repository as unusable.
> diff --git a/setup.c b/setup.c
> index 186815c780..a97280cafe 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -918,6 +918,13 @@ int verify_repository_format(const struct repository_format *format,
> return -1;
> }
>
> + if (format->compat_hash_algo == format->hash_algo) {
> + strbuf_addf(err, _("'%s' is '%s', the same as the object format"),
> + "extensions.compatObjectFormat",
> + hash_algos[format->hash_algo].name);
> + return -1;
> + }
> +
> return 0;
> }
Putting this check in verify_repository_format() relies on two
invariants from read_repository_format() and handle_extension().
- '.hash_algo' is initialized to GIT_HASH_SHA1_LEGACY and never set to
GIT_HASH_UNKNOWN, so an unset '.compat_hash_algo' (0) cannot
spuriously equal '.hash_algo'.
- checking after the full config is parsed catches the mismatch
regardless of whether extensions.compatObjectFormat appears before or
after extensions.objectFormat (or without extensions.objectFormat at
all).
Returning -1 here also makes gentle setup warn and fall back to non-git
mode instead of aborting, so commands like "git config unset --file=..."
can recover the repository, and non-Rust builds would report the same
error.
next prev parent reply other threads:[~2026-12-06 0:38 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 19:57 [PATCH 0/3] compatObjectFormat: fix a BUG(), wrong id and unknown headers Adrian Ratiu
2026-11-12 19:57 ` [PATCH 1/3] setup: reject compatObjectFormat == objectFormat Adrian Ratiu
2026-11-16 7:36 ` Patrick Steinhardt
2026-11-17 10:42 ` Adrian Ratiu
2026-11-12 19:57 ` [PATCH 2/3] rev-parse: die when --output-object-format cannot map an object Adrian Ratiu
2026-11-16 7:37 ` Patrick Steinhardt
2026-11-17 11:55 ` Adrian Ratiu
2026-11-12 19:57 ` [PATCH 3/3] object-file-convert: copy unknown commit headers unchanged Adrian Ratiu
2026-11-16 7:37 ` Patrick Steinhardt
2026-11-17 15:27 ` Adrian Ratiu
2026-11-19 14:18 ` [PATCH v2 0/3] compatObjectFormat: fix a BUG(), wrong ID and unknown headers Adrian Ratiu
2026-11-19 14:18 ` [PATCH v2 1/3] setup: reject compatObjectFormat == objectFormat Adrian Ratiu
2026-11-20 22:21 ` Junio C Hamano
2026-11-19 14:18 ` [PATCH v2 2/3] rev-parse: die when --output-object-format cannot map an object Adrian Ratiu
2026-11-20 22:29 ` Junio C Hamano
2026-11-23 16:12 ` Adrian Ratiu
2026-11-19 14:18 ` [PATCH v2 3/3] object-file-convert: copy unknown commit headers unchanged Adrian Ratiu
2026-11-20 22:41 ` Junio C Hamano
2026-11-23 16:41 ` Adrian Ratiu
2026-11-21 0:30 ` Junio C Hamano
2026-11-21 19:08 ` Junio C Hamano
2026-11-23 16:16 ` Adrian Ratiu
2026-11-21 2:59 ` [PATCH v2 0/3] compatObjectFormat: fix a BUG(), wrong ID and unknown headers Junio C Hamano
2026-11-30 13:43 ` [PATCH v3 0/4] " Adrian Ratiu
2026-11-30 13:43 ` [PATCH v3 1/4] setup: reject compatObjectFormat == objectFormat Adrian Ratiu
2026-12-06 0:38 ` Junio C Hamano [this message]
2026-11-30 13:43 ` [PATCH v3 2/4] rev-parse: die when --output-object-format cannot map an object Adrian Ratiu
2026-12-06 1:08 ` Junio C Hamano
2026-11-30 13:43 ` [PATCH v3 3/4] object-file-convert: match tree, parent and mergetag headers by key Adrian Ratiu
2026-12-01 8:15 ` Patrick Steinhardt
2026-12-01 11:29 ` Adrian Ratiu
2026-11-30 13:43 ` [PATCH v3 4/4] object-file-convert: copy unknown commit headers unchanged Adrian Ratiu
2026-12-04 17:47 ` Eric W. Biederman
2026-12-04 21:25 ` Adrian Ratiu
2026-12-06 0:38 ` [PATCH v3 0/4] compatObjectFormat: fix a BUG(), wrong ID and unknown headers 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq33sbi6ow.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=adrian.ratiu@collabora.com \
--cc=ebiederm@xmission.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
/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