Skip to contentSkip to conversation

repo-info: add paths.git_dir field

PATCH New jayesh0104 1 participant 1 message Mar 6

lore
Share & tools
lore

jayesh0104

author
#0 lore raw

PATCH 1/1 repo-info: add paths.git_dir field

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.

---
 builtin/repo.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
builtin/repo.c +6 -1
index f943be7451..7535192878 100644
@@ -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 },
 };
 
Signature · 1 line
2.43.0