Thread (5 messages) 5 messages, 2 authors, 2026-02-27

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

From: Lucas Seiki Oshiro <hidden>
Date: 2026-02-25 19:37:21

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.
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.
+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.
quoted hunk ↗ jump to hunk
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!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help