git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] unpack-trees: use repository from index instead of global

From
Jayesh Daga via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 31, 2026, 15:34 UTC
Message-ID
<fbdf3271b7b05d9e3afc9aa3d476ccd64f867d08.1774971267.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2258.v2.git.git.1774971267.gitgitgadget@gmail.com>
From: Jayesh Daga <jayeshdaga99@gmail.com>

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 is a step towards eliminating global repository usage in unpack_trees().

Suggested-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com>
---
 unpack-trees.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 191b9d4769..b42020f16b 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1882,7 +1882,7 @@ static int verify_absent(const struct cache_entry *,
  */
 int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
 {
-	struct repository *repo = the_repository;
+	struct repository *repo = o->src_index->repo;
 	int i, ret;
 	static struct cache_entry *dfc;
 	struct pattern_list pl;
-- 
gitgitgadget
Previous: Jayesh Daga via GitGitGadgetNext: Junio C Hamano
Message 7 of 9 in “unpack-trees: use explicit repository in trace2 calls”
  1. unpack-trees: use explicit repository in trace2 callsJayesh Daga via GitGitGadget, Mar 30, 2026
  2. Patrick SteinhardtMar 31, 2026
  3. Junio C HamanoMar 31, 2026
  4. Junio C HamanoMar 31, 2026
  5. 0/2 unpack-trees: use explicit repository in trace2 callsJayesh Daga via GitGitGadget, Mar 31, 2026
  6. 1/2 unpack-trees: use repository from index instead of globalJayesh Daga via GitGitGadget, Mar 31, 2026
  7. 2/2 unpack-trees: use repository from index instead of globalJayesh Daga via GitGitGadget, Mar 31, 2026
  8. Junio C HamanoMar 31, 2026
  9. Junio C HamanoJun 9, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.