public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Ayush Jha <kumarayushjha123@gmail.com>
To: git@vger.kernel.org
Cc: Christian Couder <christian.couder@gmail.com>,
	Karthik Nayak <karthik.188@gmail.com>,
	Justin Tobler <jltobler@gmail.com>,
	Ayush Chandekar <ayu.chandekar@gmail.com>,
	Siddharth Asthana <siddharthasthana31@gmail.com>,
	Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>,
	Ayush Jha <kumarayushjha123@gmail.com>
Subject: [RFC GSoC PATCH v3 2/2] attr: use local repository state in read_attr
Date: Sun,  8 Feb 2026 13:29:05 +0530	[thread overview]
Message-ID: <20260208075905.1807-2-kumarayushjha123@gmail.com> (raw)
In-Reply-To: <20260208075905.1807-1-kumarayushjha123@gmail.com>

The read_attr function currently relies on is_bare_repository() to decide whether to check the index or working tree for attributes. This function implicitly depends on the_repository, which is incorrect for library code handling secondary repositories.

Update read_attr to use the new  repo_settings_get_is_bare(istate->repo)
helper. This ensures the logic respects the context of the specific repository associated with the index, while also benefiting from the lazy-loading optimization added in the previous commit.

Signed-off-by: Ayush Jha <kumarayushjha123@gmail.com>
---
 attr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/attr.c b/attr.c
index 4999b7e09d..2e1cde4615 100644
--- a/attr.c
+++ b/attr.c
@@ -23,6 +23,7 @@
 #include "refs.h"
 #include "revision.h"
 #include "odb.h"
+#include "repo-settings.h"
 #include "setup.h"
 #include "thread-utils.h"
 #include "tree-walk.h"
@@ -848,7 +849,7 @@ static struct attr_stack *read_attr(struct index_state *istate,
 		res = read_attr_from_index(istate, path, flags);
 	} else if (tree_oid) {
 		res = read_attr_from_blob(istate, tree_oid, path, flags);
-	} else if (!is_bare_repository()) {
+	} else if (!repo_settings_get_is_bare(istate->repo)) {
 		if (direction == GIT_ATTR_CHECKOUT) {
 			res = read_attr_from_index(istate, path, flags);
 			if (!res)
-- 
2.53.0.windows.1


      reply	other threads:[~2026-02-08  7:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-08  7:59 [RFC GSoC PATCH v3 1/2] repo-settings: add repo_settings_get_is_bare Ayush Jha
2026-02-08  7:59 ` Ayush Jha [this message]

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=20260208075905.1807-2-kumarayushjha123@gmail.com \
    --to=kumarayushjha123@gmail.com \
    --cc=ayu.chandekar@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jltobler@gmail.com \
    --cc=karthik.188@gmail.com \
    --cc=lucasseikioshiro@gmail.com \
    --cc=siddharthasthana31@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