unpack-trees: use explicit repository in trace2 calls#2258
unpack-trees: use explicit repository in trace2 calls#2258jayesh0104 wants to merge 1 commit intogit:masterfrom
Conversation
|
/submit |
|
Submitted as pull.2258.git.git.1774901607564.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
|
This patch series was integrated into seen via 0c1d458. |
717da16 to
f03ea19
Compare
|
/submit |
|
Submitted as pull.2258.v2.git.git.1774971267.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
|
This branch is now known as |
|
This patch series was integrated into seen via 6407076. |
unpack_trees() currently initializes its repository from the global 'the_repository', even though a repository instance is already available via the source index. Use 'o->src_index->repo' instead of the global variable, reducing reliance on global repository state. This clarifies the data flow and is a step towards eliminating global repository usage. Suggested-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com>
fbdf327 to
f4cf317
Compare
|
This patch series was integrated into seen via 916c387. |
|
This patch series was integrated into seen via a61a5fc. |
|
This patch series was integrated into seen via ee8a57b. |
|
This patch series was integrated into seen via a421c81. |
|
This patch series was integrated into seen via d59b6cd. |
|
There was a status update in the "New Topics" section about the branch A handful of inappropriate uses of the_repository have been rewritten to use the right repository structure instance in the unpack-trees.c codepath. Will merge to 'next'. source: <pull.2258.git.git.1774901607564.gitgitgadget@gmail.com> |
|
Patrick Steinhardt wrote on the Git mailing list (how to reply to this email): On Mon, Mar 30, 2026 at 08:13:27PM +0000, Jayesh Daga via GitGitGadget wrote:
> From: Jayesh Daga <jayeshdaga99@gmail.com>
> diff --git a/unpack-trees.c b/unpack-trees.c
> index 998a1e6dc7..191b9d4769 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1903,7 +1903,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
> BUG("o->df_conflict_entry is an output only field");
>
> trace_performance_enter();
> - trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
> + trace2_region_enter("unpack_trees", "unpack_trees", repo);
>
> prepare_repo_settings(repo);
> if (repo->settings.command_requires_full_index) {
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()`?
Once that's done we only have a handful of other places, and in all but
two cases we have a repository available via the index. Do we maybe want
to go all the way so that we can drop `USE_THE_REPOSITORY_VARIABLE` at
the end of this series?
Thanks!
Patrick |
|
User |
|
Junio C Hamano wrote on the Git mailing list (how to reply to this email): Patrick Steinhardt <ps@pks.im> 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. |
|
Junio C Hamano wrote on the Git mailing list (how to reply to this email): Junio C Hamano <gitster@pobox.com> writes:
> Patrick Steinhardt <ps@pks.im> 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.
Actually, assert(dst_index->repo == src_index->repo) is probably not
what we want, as dst_index can legitimately be NULL, even since
34110cd4 (Make 'unpack_trees()' have a separate source and
destination index, 2008-03-06) introduced srparete src/dst indices
to unpack_trees() API.
We will always unpack into our own internal index, but we will take the
source from wherever specified, and we will optionally write the result
to a specified index (optionally, because not everybody even _wants_ any
result: the index diffing really wants to just walk the tree and index
in parallel).
So o->src_index->repo is what we want in this case, I think. |
|
Junio C Hamano wrote on the Git mailing list (how to reply to this email): "Jayesh Daga via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Jayesh Daga (2):
> unpack-trees: use repository from index instead of global
> unpack-trees: use repository from index instead of global
That is unusual to have two commits with identical title and
identical proposed log messages yet with different patch text.
Do you perhaps want to squash them into a single commit? |
|
There was a status update in the "New Topics" section about the branch A handful of inappropriate uses of the_repository have been rewritten to use the right repository structure instance in the unpack-trees.c codepath. Will merge to 'next'. source: <pull.2258.git.git.1774901607564.gitgitgadget@gmail.com> |
|
Patrick Steinhardt wrote on the Git mailing list (how to reply to this email): On Mon, Mar 30, 2026 at 08:13:27PM +0000, Jayesh Daga via GitGitGadget wrote:
> From: Jayesh Daga <jayeshdaga99@gmail.com>
> diff --git a/unpack-trees.c b/unpack-trees.c
> index 998a1e6dc7..191b9d4769 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -1903,7 +1903,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
> BUG("o->df_conflict_entry is an output only field");
>
> trace_performance_enter();
> - trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
> + trace2_region_enter("unpack_trees", "unpack_trees", repo);
>
> prepare_repo_settings(repo);
> if (repo->settings.command_requires_full_index) {
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()`?
Once that's done we only have a handful of other places, and in all but
two cases we have a repository available via the index. Do we maybe want
to go all the way so that we can drop `USE_THE_REPOSITORY_VARIABLE` at
the end of this series?
Thanks!
Patrick |
|
There was a status update in the "Cooking" section about the branch A handful of inappropriate uses of the_repository have been rewritten to use the right repository structure instance in the unpack-trees.c codepath. Comments? source: <pull.2258.v2.git.git.1774971267.gitgitgadget@gmail.com> |
|
This patch series was integrated into seen via 6306f22. |
|
This patch series was integrated into seen via 892c268. |
|
There was a status update in the "Cooking" section about the branch A handful of inappropriate uses of the_repository have been rewritten to use the right repository structure instance in the unpack-trees.c codepath. Comments? source: <pull.2258.v2.git.git.1774971267.gitgitgadget@gmail.com> |
|
This patch series was integrated into seen via c48cb4b. |
trace2 calls in unpack-trees.c use the global 'the_repository',
even though the relevant context provides an explicit repository
pointer via 'istate->repo' or the local 'repo' variable.
Using the global repository can result in incorrect trace2 output
when multiple repository instances are in use, as events may be
attributed to the wrong repository.
Use explicit repository pointers instead in these call sites to
ensure correct repository attribution.
Signed-off-by: Jayesh Daga jayeshdaga99@gmail.com
v3:
v2:
cc :Karthik Nayak karthik.188@gmail.com
cc: Justin Tobler jltobler@gmail.com
cc: Ayush Chandekar ayu.chandekar@gmail.com
cc: Siddharth Asthana siddharthasthana31@gmail.com
cc: Patrick Steinhardt ps@pks.im