🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
2 messages
2 total messages Started by Adrian Ratiu Thu, 12 Nov 2026 19:57
[PATCH 1/3] setup: reject compatObjectFormat == objectFormat
#3029
Author: Adrian Ratiu
Date: Thu, 12 Nov 2026 19:57
68 lines
11772 bytes
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.

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..52a9462edd 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..858aea62a5 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 core.repositoryformatversion 1 &&
+		git -C same config 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 --file=same/.git/config --unset 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 &&
-- 
2.56.1
Re: [PATCH 1/3] setup: reject compatObjectFormat == objectFormat
#3226
Author: Adrian Ratiu
Date: Tue, 17 Nov 2026 10:42
51 lines
11103 bytes
On Mon, 16 Nov 2026, Patrick Steinhardt <ps@pks.im> wrote:
> On Thu, Nov 12, 2026 at 09:57:38PM +0200, Adrian Ratiu wrote:
>> diff --git a/setup.c b/setup.c
>> index 186815c780..52a9462edd 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",
>
> We should rather say "extensions.compatObjectFormat" here with proper
> casing, as this is user-facing.

Ack, will do in v2.

>> +			    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..858aea62a5 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 core.repositoryformatversion 1 &&
>> +		git -C same config 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 --file=same/.git/config --unset extensions.compatObjectFormat &&
>
> Nit: do we maybe want to use the modern alternate `git config unset`? If
> so, we should probably be consistent and also use `gi tconfig set`
> further up.

Ack, will do in v2.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads