public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH 2/2] repo: add the field path.common-dir
       [not found] <0260301134412.1072596-2-pushkarkumarsingh1970@gmail.com>
@ 2026-03-01 14:01 ` Pushkar Singh
  0 siblings, 0 replies; 2+ messages in thread
From: Pushkar Singh @ 2026-03-01 14:01 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] 2+ 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 14:03 ` Pushkar Singh
  0 siblings, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2026-03-01 14:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0260301134412.1072596-2-pushkarkumarsingh1970@gmail.com>
2026-03-01 14:01 ` [PATCH 2/2] repo: add the field path.common-dir Pushkar Singh
2026-03-01 13:44 [PATCH 0/2] repo info: add path.git-dir and path.common-dir Pushkar Singh
2026-03-01 14:03 ` [PATCH 2/2] repo: add the field path.common-dir Pushkar Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox