From: Junio C Hamano Date: Fri, 11 Sep 2026 17:37:48 GMT Subject: Re: [GSoC Patch v6 7/7] repo: add path.cdup Message-ID: In-Reply-To: <20260911144519.1011780-8-jayatheerthkulkarni2005@gmail.com> K Jayatheerth writes: > Scripts sometimes need the relative path from the current working > directory to the repository's working tree root (cdup). While this > information can be retrieved through `git rev-parse --show-cdup`, > `git repo info` does not currently expose it as a scriptable key. > > Introduce the `path.cdup` key to `git repo info`. The key returns the > path from the current working directory to the root of the working tree, > returning the empty string when invoked from the working tree root. > > Mentored-by: Justin Tobler > Mentored-by: Lucas Seiki Oshiro > Signed-off-by: K Jayatheerth > --- > Documentation/git-repo.adoc | 5 +++++ > builtin/repo.c | 15 +++++++++++++++ > t/t1900-repo-info.sh | 23 +++++++++++++++++++++++ > 3 files changed, 43 insertions(+) > > diff --git a/Documentation/git-repo.adoc b/Documentation/git-repo.adoc > index fb5aceae8f..0a30c0d6ab 100644 > --- a/Documentation/git-repo.adoc > +++ b/Documentation/git-repo.adoc > @@ -104,6 +104,11 @@ values that they return: > `object.format`:: > The object format (hash algorithm) used in the repository. > > +`path.cdup`:: > + The path to the root of the working tree relative to the current > + working directory. Returns the empty string when the current > + working directory is the root of the working tree. What happens when the current working directory is outside the working tree? For example: $ GIT_WORK_TREE=/tmp/x; export GIT_WORK_TREE $ GIT_DIR=$(pwd)/.git; export GIT_DIR The current implementation yields an empty string: $ git repo info path.cdup path.cdup= However, 'git rev-parse --show-cdup' produces: $ git rev-parse --show-cdup /var/tmp/x Whether this discrepancy matters is unclear. However, if the goal is to consolidate all repository path-related items under the 'git repo info' umbrella, this difference sticks out.