git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 v2 1/3] setup: reject compatObjectFormat == objectFormat
Date: Fri, 20 Nov 2026 14:21:34 -0800	[thread overview]
Message-ID: <xmqqmrr3nnyp.fsf@gitster.g> (raw)
In-Reply-To: <f74a0fd67af600f45bdb7560253c747aab073c65.1794932695.git.adrian.ratiu@collabora.com> (Adrian Ratiu's message of "Thu, 19 Nov 2026 16:18:20 +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.
>
> Check for this in verify_repository_format(), next to the other
> repo format checks, and return an error instead.
>
> The check runs before any of the Rust-only code. Builds without
> Rust, which so far died because compatObjectFormat requires Rust,
> now get the same error, so the test needs no RUST prereq.

And the condition that triggers this response is not a BUG() but a
repository that is incorrectly configured, so an error message is
much more appropriate.  Makes sense.

> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
> ---
>  setup.c                 |  7 +++++++
>  t/t1302-repo-version.sh | 14 ++++++++++++++
>  2 files changed, 21 insertions(+)
>
> 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;
>  }
>  
> diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh
> index 69723b88ff..718dafc95c 100755
> --- a/t/t1302-repo-version.sh
> +++ b/t/t1302-repo-version.sh
> @@ -98,6 +98,20 @@ abort 0 noop-v1
>  allow 1 noop-v1
>  EOF
>  
> +for hash in sha1 sha256
> +do
> +	test_expect_success "compatObjectFormat equal to objectFormat $hash" "
> +		test_when_finished 'rm -rf same' &&
> +		git init --object-format=$hash same &&
> +		git -C same config set core.repositoryformatversion 1 &&
> +		git -C same config set extensions.compatObjectFormat $hash &&
> +		test_must_fail git -C same rev-parse --git-dir 2>err &&
> +		test_grep \"'extensions.compatObjectFormat' is '$hash', the same as the object format\" err &&
> +		git config unset --file=same/.git/config extensions.compatObjectFormat &&
> +		git -C same rev-parse --git-dir
> +	"
> +done
> +
>  test_expect_success 'precious-objects allowed' '
>  	git config core.repositoryFormatVersion 1 &&
>  	git config extensions.preciousObjects 1 &&

  reply	other threads:[~2026-11-20 22:21 UTC|newest]

Thread overview: 17+ 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 [this message]
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-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

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=xmqqmrr3nnyp.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;
as well as URLs for NNTP newsgroup(s).