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

[PATCH v3 1/2] repo: add paths.git_dir repo info key

From
jayesh0104 via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 30, 2026, 17:27 UTC
Message-ID
<5a8165b05dad6143c910105be832bdc6ea5bf598.1774891667.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2253.v3.git.git.1774891667.gitgitgadget@gmail.com>
From: jayesh0104 <jayeshdaga99@gmail.com>

Introduce a new repo info key `paths.git_dir` to expose the repository's gitdir path, equivalent to `git rev-parse --git-dir`.

This improves consistency and allows tools to retrieve the gitdir path without invoking external commands.

The implementation adds support in repo.c and integrates it into the repo info reporting mechanism. Documentation is updated to describe the new key, and tests are added to verify that the value matches the output of `git rev-parse --git-dir`.

Signed-off-by: jayesh0104 <jayeshdaga99@gmail.com>
---
 Documentation/git-repo.adoc |  5 +++++
 builtin/repo.c              |  7 +++++++
 t/t1900-repo-info.sh        | 10 ++++++++++
 3 files changed, 22 insertions(+)
diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc
index 42262c1983..d17d911ec6 100644
--- a/Documentation/git-repo.adoc
+++ b/Documentation/git-repo.adoc
@@ -95,6 +95,11 @@ In order to obtain a set of values from `git repo info`, you should provide
 the keys that identify them. Here's a list of the available keys and the
 values that they return:
 
+`paths.git_dir`::
+	The path to the Git directory for the repository (equivalent to
+	`git rev-parse --git-dir`).
+
+
 `layout.bare`::
 	`true` if this is a bare repository, otherwise `false`.
 
diff --git a/builtin/repo.c b/builtin/repo.c
index 55f9b9095c..3067107cad 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -66,11 +66,18 @@ static int get_references_format(struct repository *repo, struct strbuf *buf)
 	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 },
 };
 
diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh
index a9eb07abe8..63be0849c4 100755
--- a/t/t1900-repo-info.sh
+++ b/t/t1900-repo-info.sh
@@ -149,4 +149,14 @@ test_expect_success 'git repo info --keys uses lines as its default output forma
 	test_cmp expect actual
 '
 
+test_expect_success 'paths.git_dir matches rev-parse --git-dir' '
+	git init repo &&
+	(
+		cd repo &&
+		git repo info paths.git_dir >actual &&
+		echo "paths.git_dir=$(git rev-parse --git-dir)" >expect &&
+		test_cmp expect actual
+	)
+'
+
 test_done
-- 
gitgitgadget
Previous: Jayesh Daga via GitGitGadgetNext: Jayesh Daga via GitGitGadget
Message 9 of 14 in “read-cache: use index state repository for trace2 logging”
  1. read-cache: use index state repository for trace2 loggingJayesh Daga via GitGitGadget, Mar 27, 2026
  2. Derrick StoleeMar 27, 2026
  3. Junio C HamanoMar 27, 2026
  4. jayesh0104Mar 28, 2026
  5. read-cache: use istate->repo for trace2 loggingJayesh Daga via GitGitGadget, Mar 28, 2026
  6. Junio C HamanoMar 28, 2026
  7. Derrick StoleeMar 29, 2026
  8. 0/2 [GSoC] read-cache: use index state repository for trace2 loggingJayesh Daga via GitGitGadget, Mar 30, 2026
  9. 1/2 repo: add paths.git_dir repo info keyjayesh0104 via GitGitGadget, Mar 30, 2026
  10. 2/2 read-cache: use istate->repo for trace2 loggingJayesh Daga via GitGitGadget, Mar 30, 2026
  11. read-cache: use istate->repo for trace2 loggingJayesh Daga via GitGitGadget, Mar 30, 2026
  12. Junio C HamanoMar 30, 2026
  13. Derrick StoleeApr 2, 2026
  14. Jayesh DagaApr 2, 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.