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

[PATCH] [RFC][GSoC 2026] builtin/repo: avoid global state in get_layout_bare

From
AJAyush Jha <kumarayushjha123@gmail.com>
Date
Feb 6, 2026, 15:20 UTC
Message-ID
<20260206152002.1244-1-kumarayushjha123@gmail.com>

The get_layout_bare() function accepts a struct repository *repo argument but marks it UNUSED and instead relies on is_bare_repository(), which depends on global state.

As bareness is a per-repository property, this causes the function to always report the status of the global repository, even when a specific repository instance is provided.

This change computes the bare status using the passed-in repository instance (based on core.bare and the absence of a worktree), thereby removing the dependency on global state.

This patch is sent as an RFC to solicit feedback on whether using repository-local state here is the preferred approach.

Signed-off-by: Ayush Jha <kumarayushjha123@gmail.com>
---
 builtin/repo.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/builtin/repo.c b/builtin/repo.c
index 0ea045abc1..b2619cc77c 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -35,9 +35,12 @@ struct field {
 	get_value_fn *get_value;
 };
 
-static int get_layout_bare(struct repository *repo UNUSED, struct strbuf *buf)
+static int get_layout_bare(struct repository *repo, struct strbuf *buf)
 {
-	strbuf_addstr(buf, is_bare_repository() ? "true" : "false");
+	int is_bare_cfg = -1;
+	repo_config_get_bool(repo, "core.bare", &is_bare_cfg);
+
+	strbuf_addstr(buf, is_bare_cfg && !repo_get_work_tree(repo) ? "true" : "false");
 	return 0;
 }
 
-- 
2.53.0.windows.1
Next: Junio C Hamano
Message 1 of 2 in “[RFC][GSoC 2026] builtin/repo: avoid global state in get_layout_bare”
  1. [RFC][GSoC 2026] builtin/repo: avoid global state in get_layout_bareAyush Jha, Feb 6, 2026
  2. Junio C HamanoFeb 6, 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.