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

Re: [PATCH] [RFC][GSoC][PATCH] attr: use local repository state in read_attr

From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Date
Feb 7, 2026, 21:02 UTC
Message-ID
<E605A7F6-AF4D-463F-8316-6BE69AFE0369@gmail.com>
In-Reply-To
<20260207114007.40-1-kumarayushjha123@gmail.com>
Hi Ayush!

Thanks for your interest in helping git-repo-info, even though this second patch changes the focus. It was my GSoC project last year.

Nitpick: there are two [PATCH] in the subject, and usually we use
only one subject prefix. I also think that this could be a v2 of
your first patch [1]. This way, this subject should be:
"[RFC GSoC PATCH v2] attr: use local repository state in read_attr".
Tip: use `--subject-prefix='RFC GSoC PATCH'` in this case, and
set `format.subjectPrefix='GSoC PATCH'` for your future GSoC
patches.
> read_attr() currently relies on is_bare_repository(), which
> implicitly depends on the global the_repository.

So, wouldn't it be better to make is_bare_repository depend on a `struct repository *repo` instead of `the_repository`?

I don't know how feasible it is to do that, but it seems to me that your change could benefit other places that depend on that function.

> + int is_bare;
> + int is_bare_cfg = -1;
> +
> + repo_config_get_bool(istate->repo, "core.bare", &is_bare_cfg);

This function returns 0 when the config key is found. If the key can't be found, it returns 1 and doesn't touch `is_bare_cfg`. This means that if "core.bare" doesn't exist (which is unlikely, but, who knows...) we'll proceed with is_bare_cfg = -1, and...

> + is_bare = is_bare_cfg && !repo_get_work_tree(istate->repo);

since -1 is a truthy value in C, then in this case we're deciding it based on having or not a work tree. I don't know if someone with more experience than me see something wrong with this but it seems ok to me. However, I found this way a little confusing to read. Perhaps it would be clearer if it was written like this:

int is_bare;
if (repo_config_get_bool(istate->repo, "core.bare", &is_bare_cfg))
	is_bare = !repo_get_work_tree(istate->repo);
[1] 20260206152002.1244-1-kumarayushjha123@gmail.com
Previous: Tian YuchenNext: Junio C Hamano
Message 3 of 10 in “attr: use local repository state in read_attr”
  1. [RFC][GSoC][PATCH] attr: use local repository state in read_attrAyush Jha, Feb 7, 2026
  2. Tian YuchenFeb 7, 2026
  3. Lucas Seiki OshiroFeb 7, 2026
  4. Junio C HamanoFeb 7, 2026
  5. Tian YuchenFeb 8, 2026
  6. Ayush JhaFeb 10, 2026
  7. Lucas Seiki OshiroFeb 14, 2026
  8. Ayush JhaFeb 14, 2026
  9. Junio C HamanoFeb 10, 2026
  10. Tian YuchenFeb 11, 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.