Git development
 help / color / mirror / Atom feed
From: "Srujith A Poojary via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Srujith A Poojary <poojarysrujith@gmail.com>,
	Srujith A Poojary <poojarysrujith@gmail.com>
Subject: [PATCH] read-cache: use istate->repo in overlay_tree_on_index()
Date: Mon, 16 Nov 2026 10:34:29 +0000	[thread overview]
Message-ID: <pull.2315.git.1794825269464.gitgitgadget@gmail.com> (raw)

From: Srujith A Poojary <poojarysrujith@gmail.com>

Use the repository associated with the index state when
resolving the tree name, parsing the tree, and reading
its entries.

This avoids relying on the global repository when the
function already has access to its associated repository.

Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>
---
    read-cache: use istate->repo in overlay_tree_on_index()

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2315%2Fpoojarysrujith%2Flibification-overlay-tree-repo-clean-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2315/poojarysrujith/libification-overlay-tree-repo-clean-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2315

 read-cache.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 5bbfbfeceb..063ad523d2 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3874,6 +3874,7 @@ static int read_one_entry_quick(const struct object_id *oid, struct strbuf *base
 void overlay_tree_on_index(struct index_state *istate,
 			   const char *tree_name, const char *prefix)
 {
+	struct repository *repo = istate->repo;
 	struct tree *tree;
 	struct object_id oid;
 	struct pathspec pathspec;
@@ -3882,9 +3883,9 @@ void overlay_tree_on_index(struct index_state *istate,
 	read_tree_fn_t fn = NULL;
 	int err;
 
-	if (repo_get_oid(the_repository, tree_name, &oid))
+	if (repo_get_oid(repo, tree_name, &oid))
 		die("tree-ish %s not found.", tree_name);
-	tree = repo_parse_tree_indirect(the_repository, &oid);
+	tree = repo_parse_tree_indirect(repo, &oid);
 	if (!tree)
 		die("bad tree-ish %s", tree_name);
 
@@ -3919,7 +3920,7 @@ void overlay_tree_on_index(struct index_state *istate,
 
 	if (!fn)
 		fn = read_one_entry_quick;
-	err = read_tree(the_repository, tree, &pathspec, fn, istate);
+	err = read_tree(repo, tree, &pathspec, fn, istate);
 	clear_pathspec(&pathspec);
 	if (err)
 		die("unable to read tree entries %s", tree_name);

base-commit: 1891de46f79dc444a47db1c87bd0c8c76b5463f2
-- 
gitgitgadget

             reply	other threads:[~2026-11-16 10:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 10:34 Srujith A Poojary via GitGitGadget [this message]
2026-11-16 13:11 ` [PATCH] read-cache: use istate->repo in overlay_tree_on_index() Derrick Stolee
2026-11-16 16:51   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.2315.git.1794825269464.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=poojarysrujith@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox