{"thread":{"id":"65392","subject":"[PATCH] cache-tree: use index state repository in trace2 calls","startedAt":"2026-03-31T10:02:57Z","lastAt":"2026-03-31T10:02:57Z","messageCount":1,"participants":["Jayesh Daga via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"540499","messageId":"pull.2259.git.git.1774951373588.gitgitgadget@gmail.com","threadId":"65392","inReplyTo":null,"subject":"[PATCH] cache-tree: use index state repository in trace2 calls","fromName":"Jayesh Daga via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-31T10:02:53Z","receivedAt":"2026-03-31T10:02:57Z","isPatch":true,"sender":{"key":"jayeshdaga99@gmail.com","avatar":"https://avatars.githubusercontent.com/u/86013121?v=4"},"body":"From: Jayesh Daga <jayeshdaga99@gmail.com>\n\ntrace2 calls in cache-tree.c use the global 'the_repository',\neven though cache_tree_update() has access to an explicit\nrepository pointer via 'istate->repo'.\n\nUsing the global repository can result in incorrect trace2\noutput when multiple repository instances are in use, as\nevents may be attributed to the wrong repository.\n\nUse 'istate->repo' in cache_tree_update() to ensure correct\nrepository attribution.\n\nOther call sites are left unchanged as they do not have\naccess to a repository instance.\n\nSigned-off-by: Jayesh Daga <jayeshdaga99@gmail.com>\n---\n    cache-tree: use index state repository in trace2 calls\n    \n    trace2 calls in cache-tree.c use the global 'the_repository', even\n    though cache_tree_update() has access to an explicit repository pointer\n    via 'istate->repo'.\n    \n    Using the global repository can result in incorrect trace2 output when\n    multiple repository instances are in use, as events may be attributed to\n    the wrong repository.\n    \n    Use 'istate->repo' instead in these call sites to ensure correct\n    repository attribution.\n    \n    Signed-off-by: Jayesh Daga jayeshdaga99@gmail.com\n    \n    cc :Karthik Nayak karthik.188@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2259%2Fjayesh0104%2Fcache-tree-trace2-repo-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2259/jayesh0104/cache-tree-trace2-repo-v1\nPull-Request: https://github.com/git/git/pull/2259\n\n cache-tree.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 60bcc07c3b..e4f9174c4a 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -488,12 +488,12 @@ int cache_tree_update(struct index_state *istate, int flags)\n \t\tprefetch_cache_entries(istate, must_check_existence);\n \n \ttrace_performance_enter();\n-\ttrace2_region_enter(\"cache_tree\", \"update\", the_repository);\n+\ttrace2_region_enter(\"cache_tree\", \"update\", istate->repo);\n \ttransaction = odb_transaction_begin(the_repository->objects);\n \ti = update_one(istate->cache_tree, istate->cache, istate->cache_nr,\n \t\t       \"\", 0, &skip, flags);\n \todb_transaction_commit(transaction);\n-\ttrace2_region_leave(\"cache_tree\", \"update\", the_repository);\n+\ttrace2_region_leave(\"cache_tree\", \"update\", istate->repo);\n \ttrace_performance_leave(\"cache_tree_update\");\n \tif (i < 0)\n \t\treturn i;\n\nbase-commit: 5361983c075154725be47b65cca9a2421789e410\n-- \ngitgitgadget\n"}]}