repository: require Rust support for interoperability
We'll be implementing some of our interoperability code, like the loose
object map, in Rust. While the code currently compiles with the old
loose object map format, which is written entirely in C, we'll soon
replace that with the Rust-based implementation.
Require the use of Rust for compatibility mode and die if it is not
supported. Because the repo argument is not used when Rust is missing,
cast it to void to silence the compiler warning, which we do not care
about.
Add a prerequisite in our tests, RUST, that checks if Rust functionality
is available and use it in the tests that handle interoperability.
This is technically a regression in functionality compared to our
existing state, but pack index v3 is not yet implemented and thus the
functionality is mostly quite broken, which is why we've recently marked
this functionality as experimental. We don't believe anyone is getting
useful use out of the interoperability code in its current state, so no
actual users should be negatively impacted by this change.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committedFeb 7, 2026 at 20:04 UTC13ecc938422b204170a3276edb427e0ff38e3670
7 files changed+77-33
repository.c
+7-1
index 46a7c99930..9ebbb7afd8 100644--- a/repository.c+++ b/repository.c@@ -3,6 +3,7 @@ #include "repository.h" #include "odb.h" #include "config.h"+#include "gettext.h" #include "object.h" #include "lockfile.h" #include "path.h"@@ -183,13 +184,18 @@ void repo_set_hash_algo(struct repository *repo, int hash_algo) repo->hash_algo = &hash_algos[hash_algo]; }-void repo_set_compat_hash_algo(struct repository *repo, int algo)+void repo_set_compat_hash_algo(struct repository *repo MAYBE_UNUSED, int algo) {+#ifdef WITH_RUST if (hash_algo_by_ptr(repo->hash_algo) == algo) BUG("hash_algo and compat_hash_algo match"); repo->compat_hash_algo = algo ? &hash_algos[algo] : NULL; if (repo->compat_hash_algo) repo_read_loose_object_map(repo);+#else+ if (algo)+ die(_("compatibility hash algorithm support requires Rust"));+#endif } void repo_set_ref_storage_format(struct repository *repo,
index 0efce53f3a..92d48b96a1 100755--- a/t/t1016-compatObjectFormat.sh+++ b/t/t1016-compatObjectFormat.sh@@ -8,6 +8,12 @@ test_description='Test how well compatObjectFormat works' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh+if ! test_have_prereq RUST+then+ skip_all='interoperability requires a Git built with Rust'+ test_done+fi+ # All of the follow variables must be defined in the environment: # GIT_AUTHOR_NAME # GIT_AUTHOR_EMAIL
t/t1500-rev-parse.sh
+1-1
index 7739ab611b..98c5a772bd 100755--- a/t/t1500-rev-parse.sh+++ b/t/t1500-rev-parse.sh@@ -208,7 +208,7 @@ test_expect_success 'rev-parse --show-object-format in repo' ' '-test_expect_success 'rev-parse --show-object-format in repo with compat mode' '+test_expect_success RUST 'rev-parse --show-object-format in repo with compat mode' ' mkdir repo && ( sane_unset GIT_DEFAULT_HASH &&
t/t9305-fast-import-signatures.sh
+2-2
index 022dae02e4..a5406793f7 100755--- a/t/t9305-fast-import-signatures.sh+++ b/t/t9305-fast-import-signatures.sh@@ -70,7 +70,7 @@ test_expect_success GPGSSH 'strip SSH signature with --signed-commits=strip' ' test_must_be_empty log '-test_expect_success GPG 'setup a commit with dual OpenPGP signatures on its SHA-1 and SHA-256 formats' '+test_expect_success RUST,GPG 'setup a commit with dual OpenPGP signatures on its SHA-1 and SHA-256 formats' ' # Create a signed SHA-256 commit git init --object-format=sha256 explicit-sha256 && git -C explicit-sha256 config extensions.compatObjectFormat sha1 &&@@ -91,7 +91,7 @@ test_expect_success GPG 'setup a commit with dual OpenPGP signatures on its SHA- test_grep -E "^gpgsig-sha256 " out '-test_expect_success GPG 'strip both OpenPGP signatures with --signed-commits=warn-strip' '+test_expect_success RUST,GPG 'strip both OpenPGP signatures with --signed-commits=warn-strip' ' git -C explicit-sha256 fast-export --signed-commits=verbatim dual-signed >output && test_grep -E "^gpgsig sha1 openpgp" output && test_grep -E "^gpgsig sha256 openpgp" output &&
t/t9350-fast-export.sh
+2-2
index 3d153a4805..784d68b6e5 100755--- a/t/t9350-fast-export.sh+++ b/t/t9350-fast-export.sh@@ -972,7 +972,7 @@ test_expect_success 'fast-export handles --end-of-options' ' test_cmp expect actual '-test_expect_success GPG 'setup a commit with dual signatures on its SHA-1 and SHA-256 formats' '+test_expect_success GPG,RUST 'setup a commit with dual signatures on its SHA-1 and SHA-256 formats' ' # Create a signed SHA-256 commit git init --object-format=sha256 explicit-sha256 && git -C explicit-sha256 config extensions.compatObjectFormat sha1 &&@@ -993,7 +993,7 @@ test_expect_success GPG 'setup a commit with dual signatures on its SHA-1 and SH test_grep -E "^gpgsig-sha256 " out '-test_expect_success GPG 'export and import of doubly signed commit' '+test_expect_success GPG,RUST 'export and import of doubly signed commit' ' git -C explicit-sha256 fast-export --signed-commits=verbatim dual-signed >output && test_grep -E "^gpgsig sha1 openpgp" output && test_grep -E "^gpgsig sha256 openpgp" output &&
t/test-lib.sh
+4
index 0fb76f7d11..209498a0eb 100644--- a/t/test-lib.sh+++ b/t/test-lib.sh@@ -1891,6 +1891,10 @@ test_lazy_prereq LONG_IS_64BIT ' test 8 -le "$(build_option sizeof-long)" '+test_lazy_prereq RUST '+ test "$(build_option rust)" = enabled+'+ test_lazy_prereq TIME_IS_64BIT 'test-tool date is64bit' test_lazy_prereq TIME_T_IS_64BIT 'test-tool date time_t-is64bit'