Adrian Ratiu has been testing SHA-1/SHA-256 interoperability between Git, Gitoxide and Jujutsu, and found three more bugs in extensions.compatObjectFormat. He was reasonably confident in the first two patches and asked for careful review of the third.
In the first, setting compatObjectFormat to the same hash as the repository's object format makes every command in a Rust-enabled build abort with 'BUG: repository.c:204: hash_algo and compat_hash_algo match', including 'git config', so the bad value cannot be removed with Git. The fix is a check in verify_repository_format() that returns an error. Builds without Rust now get the same error.
In the second, 'git rev-parse --output-object-format=<compat-format>' silently prints the storage ID with exit status 0 when no compat ID is recorded, for example for objects received through index-pack. It ignored the return value of repo_oid_to_algop(), and the patch makes it die like pack-objects does.
The contentious one is about unknown commit headers. commit_tree_extended() copies them when creating a commit, but convert_commit_object() rejects them when converting an existing one. As a result 'git commit --amend' can record a compat ID that cannot be read back, failing with 'Failed to convert object from sha256 to sha1'. Ratiu made both paths copy them, which removes a check added on purpose in 08a45903cb, and he is not certain this is right.
The v3 cover letter notes changes after Junio C Hamano's review: the '<' to '<=' fix for the 'tree ', 'parent ' and 'mergetag ' headers is split into its own patch, so the empty-header lines are still rejected, and some rewording was done. Ratiu still asks Eric or Brian to look at the dropped check. Patrick Steinhardt also took part in the thread.