Adrian Ratiu has been testing sha1-sha256 interoperability between Git, Gitoxide and Jujutsu, and found three more bugs in compatObjectFormat.

First, git rev-parse --output-object-format=<compat-format> is meant to print a compat ID. Git does not record one for every object, for example those received by a fetch that goes through index-pack. In that case rev-parse ignores the return value of repo_oid_to_algop(), prints the storage ID and exits 0. The patch makes it die with the same message as pack-objects.

Second, if compatObjectFormat names the same hash as the repository's object format, every command in a Rust-enabled build aborts 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 patch adds a check in verify_repository_format() that returns an error instead, and builds without Rust now get the same error.

Third, two code paths disagree about unknown commit headers. commit_tree_extended(), used by git commit, copies them unchanged. convert_commit_object(), used by git hash-object -w and when reading a commit by its compat ID, fails on them. As a result, git commit --amend can record a compat ID that cannot be read back ("Failed to convert object from sha256 to sha1").

Ratiu made both paths copy unknown headers. That removes a check added deliberately in 08a45903cb (object-file-convert: convert commits that embed signed tags), and he says he is not certain it is the right direction. He asks reviewers to look at that patch closely.