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

[RFC GSoC PATCH v3 2/2] attr: use local repository state in read_attr

From
AJAyush Jha <kumarayushjha123@gmail.com>
Date
Feb 8, 2026, 07:59 UTC
Message-ID
<20260208075905.1807-2-kumarayushjha123@gmail.com>
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
Previous: Ayush Jha
Message 2 of 2 in “repo-settings: add repo_settings_get_is_bare”
  1. 1/2 repo-settings: add repo_settings_get_is_bareAyush Jha, Feb 8, 2026
  2. 2/2 attr: use local repository state in read_attrAyush Jha, Feb 8, 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.