git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] repo-info: add paths.git_dir field

From
jayesh0104 <jayeshdaga99@gmail.com>
Date
Mar 6, 2026, 16:18 UTC
Message-ID
<20260306161822.328127-1-jayeshdaga99@gmail.com>
Expose the repository's Git directory path through `git repo info`.
This value is currently available via:
    git rev-parse --git-dir

Adding it to `git repo info` allows scripts to retrieve it through a structured interface.

Signed-off-by: Jayesh Daga <jayeshdaga99@gmail.com>
---
 builtin/repo.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/builtin/repo.c b/builtin/repo.c
index f943be7451..7535192878 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -61,12 +61,17 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)
 		      ref_storage_format_to_name(repo->ref_storage_format));
 	return 0;
 }
-
+static int get_paths_git_dir(struct repository *repo, struct strbuf *buf)
+{
+	strbuf_addstr(buf, repo_get_git_dir(repo));
+	return 0;
+}
 /* repo_info_field keys must be in lexicographical order */
 static const struct repo_info_field repo_info_field[] = {
 	{ "layout.bare", get_layout_bare },
 	{ "layout.shallow", get_layout_shallow },
 	{ "object.format", get_object_format },
+	{ "paths.git_dir", get_paths_git_dir },
 	{ "references.format", get_references_format },
 };
 
-- 
2.43.0
Message 1 of 1 in “repo-info: add paths.git_dir field”
  1. repo-info: add paths.git_dir fieldjayesh0104, Mar 6, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.