* [PATCH 1/2] repo: add the field path.git-dir
2026-03-01 13:44 ` [PATCH 0/2] repo info: add path.git-dir and path.common-dir Pushkar Singh
@ 2026-03-01 13:59 ` Pushkar Singh
2026-03-01 14:03 ` [PATCH 2/2] repo: add the field path.common-dir Pushkar Singh
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Pushkar Singh @ 2026-03-01 13:59 UTC (permalink / raw)
To: git; +Cc: gitster, karthiknayak, lucasseikioshiro, patrick, peff,
Pushkar Singh
The flag --git-dir from git-rev-parse is commonly used by
scripts and tooling to retrieve the repository’s Git directory.
Since git repo info aims to provide structured repository
metadata, expose this information via a new field
path.git-dir.
The value respects the --path-format flag introduced earlier.
Signed-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
---
builtin/repo.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/builtin/repo.c b/builtin/repo.c
index 61cd539e05..8b4c7ae4cb 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -73,6 +73,21 @@ static int get_path_toplevel(struct repository *repo, struct strbuf *buf,
return 0;
}
+static int get_path_git_dir(struct repository *repo, struct strbuf *buf,
+ const char *prefix,
+ enum path_format_type format)
+{
+ const char *gitdir = repo_get_git_dir(repo);
+
+ if (!gitdir)
+ return error(_("unable to retrieve git directory"));
+
+ strbuf_add_path(buf, gitdir, prefix, format,
+ PATH_DEFAULT_UNMODIFIED);
+
+ return 0;
+}
+
static int get_references_format(struct repository *repo, struct strbuf *buf,
const char *prefix UNUSED,
enum path_format_type format UNUSED)
@@ -87,6 +102,7 @@ static const struct repo_info_field repo_info_field[] = {
{ "layout.bare", get_layout_bare },
{ "layout.shallow", get_layout_shallow },
{ "object.format", get_object_format },
+ { "path.git-dir", get_path_git_dir },
{ "path.toplevel", get_path_toplevel },
{ "references.format", get_references_format },
};
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 2/2] repo: add the field path.common-dir
2026-03-01 13:44 ` [PATCH 0/2] repo info: add path.git-dir and path.common-dir Pushkar Singh
2026-03-01 13:59 ` [PATCH 1/2] repo: add the field path.git-dir Pushkar Singh
@ 2026-03-01 14:03 ` Pushkar Singh
2026-03-01 16:50 ` [PATCH 0/2] repo info: add path.git-dir and path.common-dir K Jayatheerth
2026-03-01 18:48 ` Lucas Seiki Oshiro
3 siblings, 0 replies; 10+ messages in thread
From: Pushkar Singh @ 2026-03-01 14:03 UTC (permalink / raw)
To: git; +Cc: gitster, karthiknayak, lucasseikioshiro, patrick, peff,
Pushkar Singh
Expose the repository common directory through a new
path.common-dir field in git repo info.
This mirrors the information available via
git rev-parse --common-dir and allows structured
retrieval through the repo subcommand.
The value respects the --path-format flag.
Signed-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>
---
builtin/repo.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/builtin/repo.c b/builtin/repo.c
index 8b4c7ae4cb..d42ac2478b 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -88,6 +88,21 @@ static int get_path_git_dir(struct repository *repo, struct strbuf *buf,
return 0;
}
+static int get_path_common_dir(struct repository *repo, struct strbuf *buf,
+ const char *prefix,
+ enum path_format_type format)
+{
+ const char *commondir = repo_get_common_dir(repo);
+
+ if (!commondir)
+ return error(_("unable to retrieve common directory"));
+
+ strbuf_add_path(buf, commondir, prefix, format,
+ PATH_DEFAULT_RELATIVE_IF_SHARED);
+
+ return 0;
+}
+
static int get_references_format(struct repository *repo, struct strbuf *buf,
const char *prefix UNUSED,
enum path_format_type format UNUSED)
@@ -102,6 +117,7 @@ static const struct repo_info_field repo_info_field[] = {
{ "layout.bare", get_layout_bare },
{ "layout.shallow", get_layout_shallow },
{ "object.format", get_object_format },
+ { "path.common-dir", get_path_common_dir },
{ "path.git-dir", get_path_git_dir },
{ "path.toplevel", get_path_toplevel },
{ "references.format", get_references_format },
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 0/2] repo info: add path.git-dir and path.common-dir
2026-03-01 13:44 ` [PATCH 0/2] repo info: add path.git-dir and path.common-dir Pushkar Singh
2026-03-01 13:59 ` [PATCH 1/2] repo: add the field path.git-dir Pushkar Singh
2026-03-01 14:03 ` [PATCH 2/2] repo: add the field path.common-dir Pushkar Singh
@ 2026-03-01 16:50 ` K Jayatheerth
2026-03-01 18:48 ` Lucas Seiki Oshiro
3 siblings, 0 replies; 10+ messages in thread
From: K Jayatheerth @ 2026-03-01 16:50 UTC (permalink / raw)
To: pushkarkumarsingh1970
Cc: git, gitster, jtobler, karthiknayak, lucasseikioshiro, patrick,
peff
> Hi,
>
Hey Pushkar,
> Following the earlier RFC discussion about exposing repository
> paths via `git repo info`, this series adds two new fields:
>
> - path.git-dir
> - path.common-dir
> > Hi,
>
Hey Pushkar,
> Following the earlier RFC discussion about exposing repository
> paths via `git repo info`, this series adds two new fields:
>
> - path.git-dir
> - path.common-dir
>
There are no updates to t/t1900-repo-info.sh.
Since path normalization can be quite tricky across
different OS environments, we absolutely need tests to
verify how path.git-dir and path.common-dir behave
under both --path-format=absolute and --path-format=relative.
For example
In both patches, if the path returns NULL, you return an error(...).
Have you tested how this behaves if a user runs git repo info --all
This is one I could think of...
> These mirror the information available through
> `git rev-parse --git-dir` and `git rev-parse --common-dir`,
> respectively.
>
> This series builds on the recent path-related changes to
> `git repo info` (including `path.toplevel` and the
> `--path-format` flag), which are currently under review.
>
> Both fields respect the `--path-format` semantics introduced
> there.
>
The new keys haven't been added to Documentation/git-repo.adoc.
> Pushkar Singh (2):
> repo: add the field path.git-dir
> repo: add the field path.common-dir
>
> builtin/repo.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
>
> base-commit: 625c4fb2daac9879b299dd1cae2e793d2821dec0
> prerequisite-patch-id: a15d35d8ce98f550953b8d2b5766b945ae73013e
> prerequisite-patch-id: c3311a175dacc8d31ac8143f6deb36a1a46bd960
> prerequisite-patch-id: e2348c7f5cdad006aeb10ddda81a184859941c8c
> prerequisite-patch-id: 54003bdf23d570ce671626496a6622319a4ee2c8
> --
> 2.43.0
Thank you for the patch
Regards
- Jayatheerth
There are no updates to t/t1900-repo-info.sh.
Since path normalization can be quite tricky across
different OS environments, we absolutely need tests to
verify how path.git-dir and path.common-dir behave
under both --path-format=absolute and --path-format=relative.
For example
In both patches, if the path returns NULL, you return an error(...).
Have you tested how this behaves if a user runs git repo info --all
This is one I could think of...
> These mirror the information available through
> `git rev-parse --git-dir` and `git rev-parse --common-dir`,
> respectively.
>
> This series builds on the recent path-related changes to
> `git repo info` (including `path.toplevel` and the
> `--path-format` flag), which are currently under review.
>
> Both fields respect the `--path-format` semantics introduced
> there.
>
The new keys haven't been added to Documentation/git-repo.adoc.
> Pushkar Singh (2):
> repo: add the field path.git-dir
> repo: add the field path.common-dir
>
> builtin/repo.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
>
> base-commit: 625c4fb2daac9879b299dd1cae2e793d2821dec0
> prerequisite-patch-id: a15d35d8ce98f550953b8d2b5766b945ae73013e
> prerequisite-patch-id: c3311a175dacc8d31ac8143f6deb36a1a46bd960
> prerequisite-patch-id: e2348c7f5cdad006aeb10ddda81a184859941c8c
> prerequisite-patch-id: 54003bdf23d570ce671626496a6622319a4ee2c8
> --
> 2.43.0
Thank you for the patch
Regards
- Jayatheerth
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] repo info: add path.git-dir and path.common-dir
2026-03-01 13:44 ` [PATCH 0/2] repo info: add path.git-dir and path.common-dir Pushkar Singh
` (2 preceding siblings ...)
2026-03-01 16:50 ` [PATCH 0/2] repo info: add path.git-dir and path.common-dir K Jayatheerth
@ 2026-03-01 18:48 ` Lucas Seiki Oshiro
2026-03-01 19:34 ` Pushkar Singh
2026-03-02 16:50 ` Junio C Hamano
3 siblings, 2 replies; 10+ messages in thread
From: Lucas Seiki Oshiro @ 2026-03-01 18:48 UTC (permalink / raw)
To: Pushkar Singh; +Cc: git, gitster, karthiknayak, peff, jtobler, patrick
> Hi,
Hi!
> Following the earlier RFC discussion about exposing repository
> paths via `git repo info`, this series adds two new fields:
>
> - path.git-dir
> - path.common-dir
It's too early to send this. The first patch wasn't accepted yet
(and I really don't think that it will be in v1)
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 0/2] repo info: add path.git-dir and path.common-dir
2026-03-01 18:48 ` Lucas Seiki Oshiro
@ 2026-03-01 19:34 ` Pushkar Singh
2026-03-02 16:50 ` Junio C Hamano
1 sibling, 0 replies; 10+ messages in thread
From: Pushkar Singh @ 2026-03-01 19:34 UTC (permalink / raw)
To: Lucas Seiki Oshiro; +Cc: git, gitster, karthiknayak, peff, jtobler, patrick
Hi Lucas,
> It's too early to send this. The first patch wasn't accepted yet
> (and I really don't think that it will be in v1)
That makes sense...
Thanks for pointing it out.
I will wait until the path-related series stabilizes before iterating
further on top of it. In the meantime, I will hold off on sending a v2
of this series.
Thanks for the guidance.
Pushkar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] repo info: add path.git-dir and path.common-dir
2026-03-01 18:48 ` Lucas Seiki Oshiro
2026-03-01 19:34 ` Pushkar Singh
@ 2026-03-02 16:50 ` Junio C Hamano
1 sibling, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2026-03-02 16:50 UTC (permalink / raw)
To: Lucas Seiki Oshiro
Cc: Pushkar Singh, git, karthiknayak, peff, jtobler, patrick
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:
>> Hi,
>
> Hi!
>
>> Following the earlier RFC discussion about exposing repository
>> paths via `git repo info`, this series adds two new fields:
>>
>> - path.git-dir
>> - path.common-dir
>
> It's too early to send this. The first patch wasn't accepted yet
> (and I really don't think that it will be in v1)
What's happening here? To me, it looks as if many people are
stomping on each others' toes, adding path.something to "repo info"
output on their own without much inter-developer coordination.
^ permalink raw reply [flat|nested] 10+ messages in thread