git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:22 UTC

Re: [GSOC RFC PATCH] builtin/repo: add path.in-worktree field

From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Date
Feb 25, 2026, 19:37 UTC
Message-ID
<05C28DD8-251A-4990-BBB2-26C144CAD982@gmail.com>
In-Reply-To
<20260225190306.39358-1-valusoutrik@gmail.com>
> Hi everyone,
Hi!
> In this patch I am trying to provide the equivalent functionality of
> 'git rev-parse --is-inside-work-tree'

I'm not sure if it should be in git-repo-info. I mean, this information is more related to the current directory than the repository itself.

Show 6 quoted lines
> I found that I could either use the 'is_inside_work_tree' inside setup.h
> which does not take anything , or use the 'is_inside_dir' from dir.h
> and use the worktree directory in the repo variable that the function
> is getting. 
> I went with the latter because the former was using 'the_repository'
> inside.

Makes sense, but this way you're re-writing `is_inside_work_tree` inside `get_path_in_worktree` but without using the is_inside_work_tree variable. I don't know what's the cost of doing this.

Something that I would question here if isn't it possible to make is_inside_work_tree accept a repository as parameter and then use it here.

> Although I am not sure if 'path.in-worktree' is the best name for it.
I think 'path.is-in-worktree' would be better.
> Also, I did run t1900-repo.sh and it was failing one test case,
> which also ran with an ok when I added the new field to REPO_INFO_KEYS.
> 
> [1] : https://git.github.io/SoC-2026-Ideas/

Everything above is not meant to be a commit message. This way, it should be placed after the scissors mark (---) or in a cover letter.

Show 14 quoted lines
> +static int get_path_in_worktree(struct repository *repo, struct strbuf *buf)
> +{
> + strbuf_addstr(buf, is_inside_dir(repo->worktree) ? "true" : "false");
> + return 0;
> +}
> +
> /* repo_info_fields keys must be in lexicographical order */
> static const struct field repo_info_fields[] = {
> { "layout.bare", get_layout_bare },
> { "layout.shallow", get_layout_shallow },
> { "object.format", get_object_format },
> + { "path.in-worktree", get_path_in_worktree },
> { "references.format", get_references_format },
> };
Ok, the process of adding a new field to repo-info is correct.
Show 11 quoted lines
> diff --git a/t/t1900-repo.sh b/t/t1900-repo.sh
> index 51d55f11a5..d793d1b8e2 100755
> --- a/t/t1900-repo.sh
> +++ b/t/t1900-repo.sh
> @@ -10,6 +10,7 @@ REPO_INFO_KEYS='
> layout.bare
> layout.shallow
> object.format
> + path.in-worktree
> references.format
> '
Test missing here.
Thanks for your interest in contributing to git-repo-info!
Previous: SoutrikDasNext: SoutrikDas
Message 2 of 8 in “builtin/repo: add path.in-worktree field”
  1. builtin/repo: add path.in-worktree fieldSoutrikDas, Feb 25, 2026
  2. Lucas Seiki OshiroFeb 25, 2026
  3. SoutrikDasFeb 26, 2026
  4. Lucas Seiki OshiroFeb 26, 2026
  5. Junio C HamanoFeb 26, 2026
  6. Lucas Seiki OshiroFeb 26, 2026
  7. SoutrikDasFeb 27, 2026
  8. Kaartic SivaraamMar 2, 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.