{"thread":{"id":"64970","subject":"[RFC] git repo info: exposing repository paths","startedAt":"2026-02-10T14:11:41Z","lastAt":"2026-03-02T16:50:57Z","messageCount":10,"participants":["Pushkar Singh","Patrick Steinhardt","K Jayatheerth","Lucas Seiki Oshiro","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"535677","messageId":"CALE2CrTt_2-9C4zCrZPBabtsWY=+Mk-bH4Jaemk=yHtfpoLjfg@mail.gmail.com","threadId":"64970","inReplyTo":null,"subject":"[RFC] git repo info: exposing repository paths","fromName":"Pushkar Singh","fromEmail":"pushkarkumarsingh1970@gmail.com","sentAt":"2026-02-10T14:11:29Z","receivedAt":"2026-02-10T14:11:41Z","isPatch":false,"sender":{"key":"pushkarkumarsingh1970@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173247767?v=4"},"body":"Hi all,\n\nI’ve been looking at the \"git repo\" command recently, mostly comparing\n\"git repo info\" with what I usually reach for via \"git rev-parse\".\n\nOne thing I noticed is that git repo info currently reports repository\nproperties like layout and formats, but none of the repository paths\nthat scripts often need.\n\nFor example, as of now:\n\ngit rev-parse --git-dir\ngit rev-parse --common-dir\ngit rev-parse --git-path hooks\n\nare commonly used by scripts and tooling to figure out where things\nactually live on disk.\n\nI wanted to ask whether it would make sense for git repo info to\neventually expose some of these as structured keys, starting with\nsomething minimal like \"git-dir\".\n\nMy idea is not to completely replace rev-parse, but to let \"git repo\ninfo\" act as a more discoverable, descriptive interface for repository\nmetadata, including paths, where appropriate.\n\nOne question I am unsure about is whether such paths should be\nreported as absolute or relative (for example, relative to the working\ntree or invocation directory), and whether git-dir would be a\nreasonable first step before considering others.\n\nI wanted to ask first before making any changes, and would appreciate\nguidance on whether this direction makes sense.\n\nThanks,\nPushkar\n"},{"id":"535765","messageId":"aYxzmjoxQHccqTAl@pks.im","threadId":"64970","inReplyTo":"CALE2CrTt_2-9C4zCrZPBabtsWY=+Mk-bH4Jaemk=yHtfpoLjfg@mail.gmail.com","subject":"Re: [RFC] git repo info: exposing repository paths","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-02-11T12:18:34Z","receivedAt":"2026-02-11T12:18:41Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nOn Tue, Feb 10, 2026 at 07:41:29PM +0530, Pushkar Singh wrote:\n> Hi all,\n> \n> I’ve been looking at the \"git repo\" command recently, mostly comparing\n> \"git repo info\" with what I usually reach for via \"git rev-parse\".\n> \n> One thing I noticed is that git repo info currently reports repository\n> properties like layout and formats, but none of the repository paths\n> that scripts often need.\n> \n> For example, as of now:\n> \n> git rev-parse --git-dir\n> git rev-parse --common-dir\n> git rev-parse --git-path hooks\n> \n> are commonly used by scripts and tooling to figure out where things\n> actually live on disk.\n> \n> I wanted to ask whether it would make sense for git repo info to\n> eventually expose some of these as structured keys, starting with\n> something minimal like \"git-dir\".\n\nYes! git-rev-parse(1) has been growing functionality over time that\nsimply doesn't have anything to do with revisions, so I think it's good\nto give such functionality a new home in git-repo(1). This has been kind\nof the original idea behind this command.\n\n> My idea is not to completely replace rev-parse, but to let \"git repo\n> info\" act as a more discoverable, descriptive interface for repository\n> metadata, including paths, where appropriate.\n> \n> One question I am unsure about is whether such paths should be\n> reported as absolute or relative (for example, relative to the working\n> tree or invocation directory), and whether git-dir would be a\n> reasonable first step before considering others.\n\nI know that Lucas had a bunch of thoughts around this. If I remember\ncorrectly, he wanted to add logic that basically allows the caller to\nchoose whether the paths should be resolved to an absolute path or not.\nI've Cc'd him.\n\nThanks!\n\nPatrick\n"},{"id":"536318","messageId":"20260218183511.17195-1-pushkarkumarsingh1970@gmail.com","threadId":"64970","inReplyTo":"aYxzmjoxQHccqTAl@pks.im","subject":"Re: [RFC] git repo info: exposing repository paths","fromName":"Pushkar Singh","fromEmail":"pushkarkumarsingh1970@gmail.com","sentAt":"2026-02-18T18:35:11Z","receivedAt":"2026-02-18T18:35:19Z","isPatch":false,"sender":{"key":"pushkarkumarsingh1970@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173247767?v=4"},"body":"Hi,\n\nOn Wed, Feb 11, 2026 at 01:18:34PM +0100, Patrick Steinhardt wrote:\n> git-rev-parse(1) has been growing functionality over time that\n> simply doesn't have anything to do with revisions, so I think it's good\n> to give such functionality a new home in git-repo(1).\n\nI spent some time going through the initial git-repo implementation\nthread [1], as well as Lucas's recent WIP series [2] adding\n\"--format=default\" and \"--keys\" support to \"git repo info\".\n\nLooking at the current implementation, it seems that adding new values\nis primarily done by extending repo_info_fields[]. With the recent\n\"--keys\" support in place, that mechanism feels like the natural place\nto expose additional repository metadata.\n\nIn that direction, I would like to explore extending the existing\n\"path.*\" namespace with a few additional stable repository paths that\nare currently obtained through \"git rev-parse\", namely:\n\n- path.git-dir\n- path.common-dir\n- path.objects-dir\n\nThese correspond to well-defined repository state and are already\navailable via helpers such as repo_get_git_dir() and\nrepo_get_common_dir(). The idea would be to add them as new entries in\nrepo_info_fields[], reusing the existing output handling, without\nintroducing new flags or changing the current structure.\n\nFor now, I am intentionally avoiding invocation-dependent values such\nas \"git-prefix\" or \"is-inside-work-tree\", and focusing only on paths\nderived directly from the repository instance.\n\nRegarding relative versus absolute semantics, I would follow the\ndirection of the ongoing \"--path-format\" discussion and align with\nwhatever default behavior is agreed upon there.\n\nIf this sounds reasonable, I can prototype support for\n\"path.git-dir\" and \"path.common-dir\" first as a minimal step and\ncontinue the discussion based on that.\n\nThanks,\nPushkar\n\n[1] Initial git-repo introduction thread:\nhttps://public-inbox.org/git/20250610152117.14826-1-lucasseikioshiro@gmail.com/t/#u\n\n[2] repo: add --format=default and --keys series:\nhttps://lore.kernel.org/git/aZLARuSCuy8wYLUA@pks.im/T/#u\n"},{"id":"537439","messageId":"20260301134412.1072596-2-pushkarkumarsingh1970@gmail.com","threadId":"64970","inReplyTo":"CALE2CrTt_2-9C4zCrZPBabtsWY=+Mk-bH4Jaemk=yHtfpoLjfg@mail.gmail.com","subject":"[PATCH 0/2] repo info: add path.git-dir and path.common-dir","fromName":"Pushkar Singh","fromEmail":"pushkarkumarsingh1970@gmail.com","sentAt":"2026-03-01T13:44:08Z","receivedAt":"2026-03-01T13:47:37Z","isPatch":true,"sender":{"key":"pushkarkumarsingh1970@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173247767?v=4"},"body":"Hi,\n\nFollowing the earlier RFC discussion about exposing repository\npaths via `git repo info`, this series adds two new fields:\n\n  - path.git-dir\n  - path.common-dir\n\nThese mirror the information available through\n`git rev-parse --git-dir` and `git rev-parse --common-dir`,\nrespectively.\n\nThis series builds on the recent path-related changes to\n`git repo info` (including `path.toplevel` and the\n`--path-format` flag), which are currently under review.\n\nBoth fields respect the `--path-format` semantics introduced\nthere.\n\nPushkar Singh (2):\n  repo: add the field path.git-dir\n  repo: add the field path.common-dir\n\n builtin/repo.c | 32 ++++++++++++++++++++++++++++++++\n 1 file changed, 32 insertions(+)\n\n\nbase-commit: 625c4fb2daac9879b299dd1cae2e793d2821dec0\nprerequisite-patch-id: a15d35d8ce98f550953b8d2b5766b945ae73013e\nprerequisite-patch-id: c3311a175dacc8d31ac8143f6deb36a1a46bd960\nprerequisite-patch-id: e2348c7f5cdad006aeb10ddda81a184859941c8c\nprerequisite-patch-id: 54003bdf23d570ce671626496a6622319a4ee2c8\n-- \n2.43.0\n\n"},{"id":"537440","messageId":"20260301135927.1072684-3-pushkarkumarsingh1970@gmail.com","threadId":"64970","inReplyTo":"20260301134412.1072596-2-pushkarkumarsingh1970@gmail.com","subject":"[PATCH 1/2] repo: add the field path.git-dir","fromName":"Pushkar Singh","fromEmail":"pushkarkumarsingh1970@gmail.com","sentAt":"2026-03-01T13:59:29Z","receivedAt":"2026-03-01T14:00:43Z","isPatch":true,"sender":{"key":"pushkarkumarsingh1970@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173247767?v=4"},"body":"The flag --git-dir from git-rev-parse is commonly used by\nscripts and tooling to retrieve the repository’s Git directory.\n\nSince git repo info aims to provide structured repository\nmetadata, expose this information via a new field\npath.git-dir.\n\nThe value respects the --path-format flag introduced earlier.\n\nSigned-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>\n---\n builtin/repo.c | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 61cd539e05..8b4c7ae4cb 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -73,6 +73,21 @@ static int get_path_toplevel(struct repository *repo, struct strbuf *buf,\n \treturn 0;\n }\n \n+static int get_path_git_dir(struct repository *repo, struct strbuf *buf,\n+\t\t\t\t const char *prefix,\n+\t\t\t\t enum path_format_type format)\n+{\n+\tconst char *gitdir = repo_get_git_dir(repo);\n+\n+\tif (!gitdir)\n+\t\treturn error(_(\"unable to retrieve git directory\"));\n+\n+\tstrbuf_add_path(buf, gitdir, prefix, format,\n+\t\t\t\t\tPATH_DEFAULT_UNMODIFIED);\n+\n+\treturn 0;\n+}\n+\n static int get_references_format(struct repository *repo, struct strbuf *buf,\n \t\t\t\t const char *prefix UNUSED,\n \t\t\t\t enum path_format_type format UNUSED)\n@@ -87,6 +102,7 @@ static const struct repo_info_field repo_info_field[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n \t{ \"object.format\", get_object_format },\n+\t{ \"path.git-dir\", get_path_git_dir },\n \t{ \"path.toplevel\", get_path_toplevel },\n \t{ \"references.format\", get_references_format },\n };\n-- \n2.43.0\n\n"},{"id":"537442","messageId":"20260301140315.1072729-2-pushkarkumarsingh1970@gmail.com","threadId":"64970","inReplyTo":"20260301134412.1072596-2-pushkarkumarsingh1970@gmail.com","subject":"[PATCH 2/2] repo: add the field path.common-dir","fromName":"Pushkar Singh","fromEmail":"pushkarkumarsingh1970@gmail.com","sentAt":"2026-03-01T14:03:16Z","receivedAt":"2026-03-01T14:03:45Z","isPatch":true,"sender":{"key":"pushkarkumarsingh1970@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173247767?v=4"},"body":"Expose the repository common directory through a new\npath.common-dir field in git repo info.\n\nThis mirrors the information available via\ngit rev-parse --common-dir and allows structured\nretrieval through the repo subcommand.\n\nThe value respects the --path-format flag.\n\nSigned-off-by: Pushkar Singh <pushkarkumarsingh1970@gmail.com>\n---\n builtin/repo.c | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/builtin/repo.c b/builtin/repo.c\nindex 8b4c7ae4cb..d42ac2478b 100644\n--- a/builtin/repo.c\n+++ b/builtin/repo.c\n@@ -88,6 +88,21 @@ static int get_path_git_dir(struct repository *repo, struct strbuf *buf,\n \treturn 0;\n }\n \n+static int get_path_common_dir(struct repository *repo, struct strbuf *buf,\n+\t\t\t\t const char *prefix,\n+\t\t\t\t enum path_format_type format)\n+{\n+\tconst char *commondir = repo_get_common_dir(repo);\n+\n+\tif (!commondir)\n+\t\treturn error(_(\"unable to retrieve common directory\"));\n+\n+\tstrbuf_add_path(buf, commondir, prefix, format,\n+\t\t\t\t\tPATH_DEFAULT_RELATIVE_IF_SHARED);\n+\n+\treturn 0;\n+}\n+\n static int get_references_format(struct repository *repo, struct strbuf *buf,\n \t\t\t\t const char *prefix UNUSED,\n \t\t\t\t enum path_format_type format UNUSED)\n@@ -102,6 +117,7 @@ static const struct repo_info_field repo_info_field[] = {\n \t{ \"layout.bare\", get_layout_bare },\n \t{ \"layout.shallow\", get_layout_shallow },\n \t{ \"object.format\", get_object_format },\n+\t{ \"path.common-dir\", get_path_common_dir },\n \t{ \"path.git-dir\", get_path_git_dir },\n \t{ \"path.toplevel\", get_path_toplevel },\n \t{ \"references.format\", get_references_format },\n-- \n2.43.0\n\n"},{"id":"537451","messageId":"20260301165051.90762-1-jayatheerthkulkarni2005@gmail.com","threadId":"64970","inReplyTo":"20260301134412.1072596-2-pushkarkumarsingh1970@gmail.com","subject":"Re: [PATCH 0/2] repo info: add path.git-dir and path.common-dir","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-01T16:50:51Z","receivedAt":"2026-03-01T16:51:04Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"> Hi,\n>\n\nHey Pushkar,\n\n> Following the earlier RFC discussion about exposing repository\n> paths via `git repo info`, this series adds two new fields:\n>\n>   - path.git-dir\n>   - path.common-dir\n> > Hi,\n>\n\nHey Pushkar,\n\n> Following the earlier RFC discussion about exposing repository\n> paths via `git repo info`, this series adds two new fields:\n>\n>   - path.git-dir\n>   - path.common-dir\n>\n\n\nThere are no updates to t/t1900-repo-info.sh.\nSince path normalization can be quite tricky across\ndifferent OS environments, we absolutely need tests to\nverify how path.git-dir and path.common-dir behave\nunder both --path-format=absolute and --path-format=relative.\n\nFor example\nIn both patches, if the path returns NULL, you return an error(...).\nHave you tested how this behaves if a user runs git repo info --all\n\nThis is one I could think of...\n\n\n> These mirror the information available through\n> `git rev-parse --git-dir` and `git rev-parse --common-dir`,\n> respectively.\n>\n> This series builds on the recent path-related changes to\n> `git repo info` (including `path.toplevel` and the\n> `--path-format` flag), which are currently under review.\n>\n> Both fields respect the `--path-format` semantics introduced\n> there.\n>\n\nThe new keys haven't been added to Documentation/git-repo.adoc.\n\n\n> Pushkar Singh (2):\n>   repo: add the field path.git-dir\n>   repo: add the field path.common-dir\n>\n>  builtin/repo.c | 32 ++++++++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n>\n>\n> base-commit: 625c4fb2daac9879b299dd1cae2e793d2821dec0\n> prerequisite-patch-id: a15d35d8ce98f550953b8d2b5766b945ae73013e\n> prerequisite-patch-id: c3311a175dacc8d31ac8143f6deb36a1a46bd960\n> prerequisite-patch-id: e2348c7f5cdad006aeb10ddda81a184859941c8c\n> prerequisite-patch-id: 54003bdf23d570ce671626496a6622319a4ee2c8\n> --\n> 2.43.0\n\nThank you for the patch\n\nRegards\n- Jayatheerth\n\n\n\nThere are no updates to t/t1900-repo-info.sh.\nSince path normalization can be quite tricky across\ndifferent OS environments, we absolutely need tests to\nverify how path.git-dir and path.common-dir behave\nunder both --path-format=absolute and --path-format=relative.\n\nFor example\nIn both patches, if the path returns NULL, you return an error(...).\nHave you tested how this behaves if a user runs git repo info --all\n\nThis is one I could think of...\n\n\n> These mirror the information available through\n> `git rev-parse --git-dir` and `git rev-parse --common-dir`,\n> respectively.\n>\n> This series builds on the recent path-related changes to\n> `git repo info` (including `path.toplevel` and the\n> `--path-format` flag), which are currently under review.\n>\n> Both fields respect the `--path-format` semantics introduced\n> there.\n>\n\nThe new keys haven't been added to Documentation/git-repo.adoc.\n\n\n> Pushkar Singh (2):\n>   repo: add the field path.git-dir\n>   repo: add the field path.common-dir\n>\n>  builtin/repo.c | 32 ++++++++++++++++++++++++++++++++\n>  1 file changed, 32 insertions(+)\n>\n>\n> base-commit: 625c4fb2daac9879b299dd1cae2e793d2821dec0\n> prerequisite-patch-id: a15d35d8ce98f550953b8d2b5766b945ae73013e\n> prerequisite-patch-id: c3311a175dacc8d31ac8143f6deb36a1a46bd960\n> prerequisite-patch-id: e2348c7f5cdad006aeb10ddda81a184859941c8c\n> prerequisite-patch-id: 54003bdf23d570ce671626496a6622319a4ee2c8\n> --\n> 2.43.0\n\nThank you for the patch\n\nRegards\n- Jayatheerth\n"},{"id":"537467","messageId":"8D232FDA-E286-48E7-8E41-ADC6645A9BC0@gmail.com","threadId":"64970","inReplyTo":"20260301134412.1072596-2-pushkarkumarsingh1970@gmail.com","subject":"Re: [PATCH 0/2] repo info: add path.git-dir and path.common-dir","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2026-03-01T18:48:58Z","receivedAt":"2026-03-01T18:49:14Z","isPatch":true,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> Hi,\n\nHi!\n\n> Following the earlier RFC discussion about exposing repository\n> paths via `git repo info`, this series adds two new fields:\n> \n>  - path.git-dir\n>  - path.common-dir\n\nIt's too early to send this. The first patch wasn't accepted yet\n(and I really don't think that it will be in v1)\n"},{"id":"537473","messageId":"CALE2CrQ8QP-cy=j+iRr7ZEog_f3y+LKd+9T78PPFfebVqg6Y5g@mail.gmail.com","threadId":"64970","inReplyTo":"8D232FDA-E286-48E7-8E41-ADC6645A9BC0@gmail.com","subject":"Re: [PATCH 0/2] repo info: add path.git-dir and path.common-dir","fromName":"Pushkar Singh","fromEmail":"pushkarkumarsingh1970@gmail.com","sentAt":"2026-03-01T19:34:56Z","receivedAt":"2026-03-01T19:35:10Z","isPatch":true,"sender":{"key":"pushkarkumarsingh1970@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173247767?v=4"},"body":"Hi Lucas,\n\n> It's too early to send this. The first patch wasn't accepted yet\n> (and I really don't think that it will be in v1)\n\nThat makes sense...\nThanks for pointing it out.\n\nI will wait until the path-related series stabilizes before iterating\nfurther on top of it. In the meantime, I will hold off on sending a v2\nof this series.\n\nThanks for the guidance.\n\nPushkar\n"},{"id":"537552","messageId":"xmqqtsuy2n0x.fsf@gitster.g","threadId":"64970","inReplyTo":"8D232FDA-E286-48E7-8E41-ADC6645A9BC0@gmail.com","subject":"Re: [PATCH 0/2] repo info: add path.git-dir and path.common-dir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-02T16:50:54Z","receivedAt":"2026-03-02T16:50:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> writes:\n\n>> Hi,\n>\n> Hi!\n>\n>> Following the earlier RFC discussion about exposing repository\n>> paths via `git repo info`, this series adds two new fields:\n>> \n>>  - path.git-dir\n>>  - path.common-dir\n>\n> It's too early to send this. The first patch wasn't accepted yet\n> (and I really don't think that it will be in v1)\n\nWhat's happening here?  To me, it looks as if many people are\nstomping on each others' toes, adding path.something to \"repo info\"\noutput on their own without much inter-developer coordination.\n\n\n\n"}]}