From: Tian Yuchen <a3205153416@gmail.com>
To: Jayesh Daga via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Cc: Karthik Nayak <karthik.188@gmail.com>,
Justin Tobler <jltobler@gmail.com>,
Ayush Chandekar <ayu.chandekar@gmail.com>,
Siddharth Asthana <siddharthasthana31@gmail.com>,
Jayesh Daga <jayeshdaga99@gmail.com>
Subject: Re: [PATCH] repo: add paths.git_dir repo info key
Date: Sun, 22 Mar 2026 11:27:32 +0800 [thread overview]
Message-ID: <90c5b9a9-b77b-43ad-9c04-a0addc058aa8@gmail.com> (raw)
In-Reply-To: <pull.2242.git.git.1773766519857.gitgitgadget@gmail.com>
Hi Jayesh,
On 3/18/26 00:55, Jayesh Daga via GitGitGadget wrote:
> 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`.
Here you promise in the commit message that paths.git_dir and git
rev-parse --git-dir are equivalent...
> > 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>
> ---
> repo: add paths.git_dir to 'git repo info'
>
> Teach git repo info a new key, paths.git_dir, which reports the
> repository’s gitdir path (equivalent to git rev-parse --git-dir).
>
> Documentation and tests are included.
>
> Tests:
>
> * make test T=t1900-repo-info.sh
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2242%2Fjayesh0104%2Fmaster-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2242/jayesh0104/master-v1
> Pull-Request: https://github.com/git/git/pull/2242
>
> 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;
> +}
> +
...But your implementation here doesn't quite feel right. Check the
git-rev-parse documentation: the output of the --git-dir argument is
context-aware and depends on your current directory.
If you are in the root directory of the repository, it gives '.git'; And
if you are in some subdirectory of the repository , it gives
'/home/user/.../repo-root/.../.git'. I don't think simply calling
'repo_get_git_dir(repo)' will achieve this functionality.
> /* 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
And you’ve only provided tests for the root directory here, which I
don’t think is sufficient. That said, considering that you’ve likely
misunderstood how to use the --git-dir parameter, this is understandable.
Next time you create a similar patch, I think you should take a close
look at the documentation and source code first, and try using the
existing commands a few times on your own to understand how they work,
right? ;)
Regards,
Yuchen
prev parent reply other threads:[~2026-03-22 3:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 16:55 [PATCH] repo: add paths.git_dir repo info key Jayesh Daga via GitGitGadget
2026-03-19 14:00 ` Karthik Nayak
2026-03-22 3:27 ` Tian Yuchen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=90c5b9a9-b77b-43ad-9c04-a0addc058aa8@gmail.com \
--to=a3205153416@gmail.com \
--cc=ayu.chandekar@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=jayeshdaga99@gmail.com \
--cc=jltobler@gmail.com \
--cc=karthik.188@gmail.com \
--cc=siddharthasthana31@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.