Re: [GSoC Patch v6 7/7] repo: add path.cdup
- From
K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
- Date
- Sep 23, 2026, 17:37 UTC
- Message-ID
- <CA+rGoLcLvm24XAeN9QOObEC2JbQaBhFmvivJ=-6OZ_t8F0Tw1A@mail.gmail.com>
- In-Reply-To
- <xmqqcxujbser.fsf@gitster.g>
On Fri, Sep 11, 2026 at 11:07 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 32 quoted lines
> > K Jayatheerth <jayatheerthkulkarni2005@gmail.com> 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. > > [...] > > +`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.
yeah in rev-parse i could find this
if (!is_inside_work_tree(the_repository)) { const char *work_tree = repo_get_work_tree(the_repository); if (work_tree) printf("%s\n", work_tree); continue; }
adding this logic in repo.c should fix it!
Thanks