Article View: linux.kernel.git
Article #3318[PATCH v2] read-cache: use istate->repo in index operations
From: "Srujith A Poojary via GitGitGad...
Date: Wed, 18 Nov 2026 18:45
Date: Wed, 18 Nov 2026 18:45
162 lines
17511 bytes
17511 bytes
From: Srujith A Poojary <poojarysrujith@gmail.com>
Use the repository associated with the index state in
add_to_index(), refresh_index(), and overlay_tree_on_index.
These functions already receive an index state, so use its
repository instead of relying on the global repository for
repository-specific configuration, progress reporting, and
tree operations.
This removes unnecessary dependencies on the global repository
from these code paths.
Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>
---
read-cache: use istate->repo in index operations
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2315%2Fpoojarysrujith%2Flibification-overlay-tree-repo-clean-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2315/poojarysrujith/libification-overlay-tree-repo-clean-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/2315
Range-diff vs v1:
1: 6eabf019e9 ! 1: 19ab253b22 read-cache: use istate->repo in overlay_tree_on_index()
@@ Metadata
Author: Srujith A Poojary <poojarysrujith@gmail.com>
## Commit message ##
- read-cache: use istate->repo in overlay_tree_on_index()
+ read-cache: use istate->repo in index operations
- Use the repository associated with the index state when
- resolving the tree name, parsing the tree, and reading
- its entries.
+ Use the repository associated with the index state in
+ add_to_index(), refresh_index(), and overlay_tree_on_index.
- This avoids relying on the global repository when the
- function already has access to its associated repository.
+ These functions already receive an index state, so use its
+ repository instead of relying on the global repository for
+ repository-specific configuration, progress reporting, and
+ tree operations.
+
+ This removes unnecessary dependencies on the global repository
+ from these code paths.
Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>
## read-cache.c ##
+@@ read-cache.c: int add_to_index(struct index_state *istate, const char *path, struct stat *st,
+ * case of the file being added to the repository matches (is folded into) the existing
+ * entry's directory case.
+ */
+- if (repo_ignore_case(the_repository)) {
++ if (repo_ignore_case(istate->repo)) {
+ adjust_dirname_case(istate, ce->name);
+ }
+ if (!(flags & ADD_CACHE_RENORMALIZE)) {
+ alias = index_file_exists(istate, ce->name,
+- ce_namelen(ce), repo_ignore_case(the_repository));
++ ce_namelen(ce), repo_ignore_case(istate->repo));
+ if (alias &&
+ !ce_stage(alias) &&
+ !ie_match_stat(istate, alias, st, ce_option)) {
+@@ read-cache.c: int add_to_index(struct index_state *istate, const char *path, struct stat *st,
+ } else
+ set_object_name_for_intent_to_add_entry(ce);
+
+- if (repo_ignore_case(the_repository) && alias && different_name(ce, alias))
++ if (repo_ignore_case(istate->repo) && alias && different_name(ce, alias))
+ ce = create_alias_ce(istate, ce, alias);
+ ce->ce_flags |= CE_ADDED;
+
+@@ read-cache.c: int refresh_index(struct index_state *istate, unsigned int flags,
+ int t2_sum_scan = 0;
+
+ if (flags & REFRESH_PROGRESS && isatty(2))
+- progress = start_delayed_progress(the_repository,
++ progress = start_delayed_progress(istate->repo,
+ _("Refresh index"),
+ istate->cache_nr);
+
@@ read-cache.c: 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)
read-cache.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 5bbfbfeceb..5ca2561e7a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -908,12 +908,12 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
* case of the file being added to the repository matches (is folded into) the existing
* entry's directory case.
*/
- if (repo_ignore_case(the_repository)) {
+ if (repo_ignore_case(istate->repo)) {
adjust_dirname_case(istate, ce->name);
}
if (!(flags & ADD_CACHE_RENORMALIZE)) {
alias = index_file_exists(istate, ce->name,
- ce_namelen(ce), repo_ignore_case(the_repository));
+ ce_namelen(ce), repo_ignore_case(istate->repo));
if (alias &&
!ce_stage(alias) &&
!ie_match_stat(istate, alias, st, ce_option)) {
@@ -934,7 +934,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
} else
set_object_name_for_intent_to_add_entry(ce);
- if (repo_ignore_case(the_repository) && alias && different_name(ce, alias))
+ if (repo_ignore_case(istate->repo) && alias && different_name(ce, alias))
ce = create_alias_ce(istate, ce, alias);
ce->ce_flags |= CE_ADDED;
@@ -1537,7 +1537,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
int t2_sum_scan = 0;
if (flags & REFRESH_PROGRESS && isatty(2))
- progress = start_delayed_progress(the_repository,
+ progress = start_delayed_progress(istate->repo,
_("Refresh index"),
istate->cache_nr);
@@ -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
Technical Details
Message-ID:
<pull.2315.v2.git.1795027523258.gitgitgadget@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75724-linux-kernel-git=dewy.ruReferences:
<pull.2315.git.1794825269464.gitgitgadget@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75724-linux-kernel-git=dewy.ru
From: gitgitgadget@gmail.com ("Srujith A Poojary via GitGitGadget")
Newsgroups: linux.kernel.git
Subject: [PATCH v2] read-cache: use istate->repo in index operations
Date: Wed, 18 Nov 2026 18:45:23 +0000
Organization: Usenet Network
Message-ID: <pull.2315.v2.git.1795027523258.gitgitgadget@gmail.com>
References: <pull.2315.git.1794825269464.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2669362"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:urBpUfKl6w5P06MbWCNhkOZGtGE= sha256:kgfMlUjTvBaHaFV1Mku+PCBCkBaQQaUvwUM91gZ6iLI=
sha1:PSCLjj4N734YqIXUp1qP1yXUFRM= sha256:yV47YSMwmIThWIFANDqvt8SpFx15YOToPoallx5fo6s=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 26F3211537E; Wed, 18 Nov 2026 21:45:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id LfL7y3hKBGZr;
Wed, 18 Nov 2026 21:45:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-75724-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 2A43A11536B; Wed, 18 Nov 2026 21:45:37 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 5EF96E72F0; Wed, 18 Nov 2026 18:45:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795027532;
b=ERATCKzY9HOcPRCVj490XqUlxManBHfzG8nDcePXc7wbaKA20nKGfDT74Xg/6d852E/7
Ccg7F4w2AvYuHchywX1Fhqx+nB4cmVHHUodjf0l61EAZXF1FsuXvsBA5PmCCvqzHKO4pl
BfUGE6NPkYxIdh7Aby6DeNWjX9tk0Y799nNiPko8hHdoggtc9SfWX3HRZh2fFVboZ3NwB
FrTCJpvADMAz3++w8ddI2X8+NScRk/coeFttepE1ZkDP8cJMgJ9BsbfJxA77Z72nB22rg
kXX4bplf5XNnLlaQ4C3vbFmCtBlF0ICNb8OrqouuiFIXX5lyEm1+dulrgo+iZ4oCICA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795027532;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Message-Id:In-Reply-To:References:From:Date:Subject:Fcc:
Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:To:Cc;
bh=Dr2J55vxIx7W5WDdLya7+BPT+6w4aDEt1J4CRsPCFtU=;
b=jfuHvVTn9rORtrvvhdA8tIMsDf0kFokdEGAsTWpP+v/ojClZBJthSVJesmySraIun7+T
s0GhJIgYqakpEt6XyXzKTVfa7xPA8ogJsuCH9EoA4EeGdQpZUMo6BMLeq1s4HzZt7/6vV
dM2GRb9J1XGcEesw97CGze6jYul0KPbYFv9XGRwWlAZ9AArdgjPo33y76EVmi0q6KkusW
FFtfPmJlqtovbwxMMdgBtrzzU/6SqB/fqCCo6hD2zff+FXS7I/qL56aVpKtyhJC5F3EgW
bz+nbWTCvhOVRYv4ZHfN2DZCLuKnmtmH/81eLVPyerdH4fML7VIo2k7cBNryav/NkXA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k25D6CCy;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 3709B60A2619;
Wed, 18 Nov 2026 18:45:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k25D6CCy
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.44
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795027531;
b=rwyNyjorGRAxbk20l4aSrbzQUcsyd1p2F7OnGQkKlyqjr15KIxu8U6709J//U2QYaywq
+ZOHI5JI8zGwh6ApDGXLA5G89DBe1ruz5MmTQRkMkL6es1VFWzbRPlliJ8SfosVvhGLg+
wE62R0QNjhAhRMCS6Q06kBZVQEM1miuASxHwVEr38WUkOJF4+ULkFh0jsaJUpeogO56bU
oa0s6jtR4dOI0FEHyARvds/g7FAPv2I5sTcBarWSFY9FfjrLJ/YYR7QFpAM4E3Fejdv9F
H5N3YvyooatPFA/h+UMx1hmj9pXfr3MZnK7Ipeg90TsHinbT6vwueq9tmnrJ0Oz04QA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795027531;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:In-Reply-To:
References:From:Date:Subject:Fcc:Content-Type:
Content-Transfer-Encoding:MIME-Version:To:Cc;
bh=Dr2J55vxIx7W5WDdLya7+BPT+6w4aDEt1J4CRsPCFtU=;
b=4WsTPj4Gpj3jJjj4LjPThi+B8dNbR4sD1tf4x4ni06pAUSP4eKmsgAunhmYHHA4bUMm9
ihuGVjMZS/QnPPykJb1ePC+8VIVTTBvETlB5ouz2VBz+5bBatiITZLrGjcTjhOy2liSbG
azBv91T1VYaUxudBmKw/gWd7mBJtrQu351f+RZNUvAbFWFHCfctz9OY55MRDOHs5/dJxQ
W99q+8pfNK3m2Emafsfif6ZOcJ6sf1MRHZnoEUf5g+AdYGNSWedG+JIe2hg0Sy42ThplD
U1C478MUzpWO2lWMFgkXyeO7W59Y4/r4E/B4aJDwSxbQ2scwZalgjuINfsojmBCPF1Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=k25D6CCy;
arc=none smtp.remote-ip=209.85.216.44
X-Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2854860A2624
for <git@vger.kernel.org>; Wed, 18 Nov 2026 18:45:24 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2854860A2624
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-3b12cb3c37bso749088a91.2
for <git@vger.kernel.org>; Wed, 18 Nov 2026 10:45:24 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795027524; x=1795632324; darn=vger.kernel.org;
h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
:subject:date:from:references:in-reply-to:message-id:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=Dr2J55vxIx7W5WDdLya7+BPT+6w4aDEt1J4CRsPCFtU=;
b=k25D6CCylKJZ6c/dk3TsEnxXo0blBjAAhreA/9pPWgVHXWgHqvCy9w+bMhIKS1k+g3
+eux4pkWK0RNvxG6vDL2VXqZpFzlb2lHva7zgIsYLSUjhuYihPab77FPpk9Mjrx0pPnE
tfukntzFTPSxvP3VnhfZVpFMU+6KLC0TvUTEchlJBa9mjQJU0Zz2xqih8PeTMlsLyY5u
lQLA367ClezkRy5ETLMsA4c6DLtspUcxxDM9zU9tFLCklnauRGrqTc5PD4LZVk18eymW
yvYspexWgHdae4vGdhhaEq6P45T3nG8WvkYcCvWyTAit5hVfQqS0YwdQY0xpFnub8jO6
YTfA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795027524; x=1795632324;
h=cc:to:mime-version:content-transfer-encoding:content-type:fcc
:subject:date:from:references:in-reply-to:message-id:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=Dr2J55vxIx7W5WDdLya7+BPT+6w4aDEt1J4CRsPCFtU=;
b=UjJunPEiiIFfQt5iRevvM9AhuYf92EY1KyufABKZkP1OetM2pTRBfqBB5UjzpLHLMj
TB9X+ocITb6ax+fR7qYd4w43cWdDJhUhnIiHLxomkBcbV3s03yTsIzRvvVjhLjEr6ccl
C04vzUQsIHg3XageqkJTogURvzesQhaxrQ6vxZFcuifOpm/nYHwIfpqkPBLjntKBLypB
yxFAHjsVFqipSvVXzDvqSI6+3nq79cRMvv58mZGjr5cELwUbshCNPECmgDSD//jfLwXV
w931yrjRc0lzEGrzrOrpQL8ED7RSBDcudumtRXNOUYd6pu7HA5jU1fJw2Q0gm12dgosN
AcbQ==
X-Gm-Message-State: APuU4Z8JZby5b/qZ3Ws1hfyODt7f6irLYuZtO1Ja2hm0ixrHG2V8A1Z+
rqbuC7tD/Gyjw26WTjvYij/TiQNlVlV1tdES28Ft3FIO0JhWigCSmIvArKLP0A==
X-Gm-Gg: AZFdTZdpGRBpE9dJlQy8ftLsyskM+1By33xAH960kX4NskuxIkqGMlov3/Wd83Max/c
tM4RcZxwn1yctGNL6EE+BDJ+h+67KgEbiP7KNS707rY+aebRr2fnTrlYOKxOAEurHCQ5xyRWfMI
j08pmGBqKvSWSMf5njSPhJFOaNr1fkyuwxSx89+S9FHqliw5Ic4E73Eb6RKGfb5MD343j8mnmGA
8g0zOjmVXRbaOPRTKXW3hGW0Eq/wGDPDZqTbXGk1NoDQunQwl2X4cMYjkhYA6q5agWoDh6yh9HM
VCwCPm2gZvY+Sjxj4Y7dStTkpqqJ36H4qL19L3GFtTMNohjcdzBtZZOsIKgxf1cI7gRnifeyW6t
L2nGjVADvZdoy/fhQ9rUeaqepoJWmPeaze+BJMRClxbadaqasUAvqJYft6cGSN9wVo3rhNjU1ne
hB7L3FcrD+gt3WzDQSWkkCtQVao9K08pI/wEEyH6zaX5ezcnD0jG8xm5ZJ5nxigGFX3NlVCfiN5
dLaIRkGYrUF5PRoRNXv9UbOJZip/qPeLH1rN86GngdyHf1gDGTIV7MuhVM7A8ZB5MTmqPXb+tQg
uqF5U3SSXKEMtT83Hufj0ioJn4Z0lue/wZ3n0DpLsCxMrxZK2KEqRsmVAuZih1AqOVNC4PjNcAP
BjoTDF+al
X-Received: by 2002:a17:90b:58ef:b0:3ac:d39d:ee4f with SMTP id 98e67ed59e1d1-3b3d07d4632mr3359814a91.44.1795027524339;
Wed, 18 Nov 2026 10:45:24 -0800 (PST)
X-Received: from [127.0.0.1] (ec2-3-42-157-126.us-west-2.compute.amazonaws.com. [3.42.157.126])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b3f7067012sm434035a91.12.2026.11.18.10.45.23
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 18 Nov 2026 10:45:23 -0800 (PST)
X-In-Reply-To: <pull.2315.git.1794825269464.gitgitgadget@gmail.com>
X-Fcc: Sent
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-Cc: Derrick Stolee <stolee@gmail.com>,
Srujith A Poojary <poojarysrujith@gmail.com>,
Srujith A Poojary <poojarysrujith@gmail.com>