Re: [PATCH 01/14] repository: require Rust support for interoperability
On Mon, Oct 27, 2025 at 12:43:51AM +0000, brian m. carlson wrote:
Show 19 quoted lines
> 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.
Yeah, I don't see much of an issue with this.
Show 16 quoted lines
> diff --git a/repository.c b/repository.c
> index 6faf5c7398..823f110019 100644
> --- a/repository.c
> +++ b/repository.c
> @@ -192,11 +193,17 @@ void repo_set_hash_algo(struct repository *repo, int hash_algo)
>
> void repo_set_compat_hash_algo(struct repository *repo, 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
> + (void)repo;You can annotate `repo` with `MAYBE_UNUSED` instead of casting.
Patrick