{"thread":{"id":"65108","subject":"[PATCH 2/2] repo: add the field path.common-dir","startedAt":"2026-03-01T14:02:00Z","lastAt":"2026-03-01T14:02:00Z","messageCount":1,"participants":["Pushkar Singh"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"537441","messageId":"20260301140137.1072709-2-pushkarkumarsingh1970@gmail.com","threadId":"65108","inReplyTo":"0260301134412.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:01:38Z","receivedAt":"2026-03-01T14:02:00Z","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"}]}