Subject: Re: [PATCH] unpack-trees: use explicit repository in trace2 calls

From: Junio C Hamano <[email-masked]>
Date: Tue, 31 Mar 2026 08:32:03 -0700

Patrick Steinhardt <[email-masked]> writes:

> The changes in `unpack_trees()` are a bit misleading -- while it reads
> as if we don't use `the_repository` anymore, we still do because the
> function starts with:
>
>   int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
>   {
>   	struct repository *repo = the_repository;
>
> So would it make sense to maybe have a separate patch where we inject a
> repository as a parameter to `unpack_trees()`?

We can see that "struct unpack_trees_options" is rich enough in the
merge context that it would be a natural place to have it unless it
is already tehre.

In fact, o->dst_index->repo should probably be what you want, and
because it would be insane to start from an index in a repo and
store the resulting updated index in another repo, there probably
needs an assert(o->dst_index->repo == o->src_index->repo) somewhere.