Subject: Re: [PATCH 0/4] repo: add support for path-related fields

From: "brian m. carlson" <[email-masked]>
Date: Sun, 1 Mar 2026 21:25:05 +0000

On 2026-02-28 at 22:05:54, Lucas Seiki Oshiro wrote:
> Hi!
> 
> This patch series adds support for path-related fields in repo-info, based on
> what we already have in git-rev-parse:
> 
> 1. The two first patches moves the path formatting used by git-rev-parse to
>    path.c. This will allow us to reuse this code in git-repo-info
> 2. The second patch add a new flag --path-format to git-repo-info, similar to
>    the flag of git-rev-parse with the same name
> 3. Add the new field `path.toplevel` as a proof of concept.
> 
> This arises from the fact that I didn't know what should be the default behavior
> of git-repo-info when dealing with paths. Some ideas were:
> 
> 1. Add --path-format, just like we have in git-rev-parse
> 2. Use what rev-parse uses by default
> 3. Add keys for both relative and absolute formats
> 
> In this case, I'm using 1, but I'm not sure if it's the best option. One
> downside that I see here is that git-repo-info won't be able to return
> a relative and an absolute path for different keys in the same call.

I think you should provide both.  I originally added this for things
like `--git-common-dir`, which Git LFS would really like to have as an
absolute path in the way that Git canonicalizes it, as well as
potentially a relative path.

The reason is that the way Git canonicalizes things on Windows is not
easily accessible on all systems or in all languages.  For instance, Go
has steadfastly refused to provide functionality for
`GetFinalPathnameByHandle`, despite that being necessary to canonicalize
the way Git does, so it's important to be able to get that information
both in a relative way and as an absolute path.

On Unix, things are easier since there are fewer special file system
objects and `realpath` or its equivalent are usually present in most
languages.

With `git rev-parse`, you can change `--path-format` on the command line
between options, so if you want both, you just request one thing, use
`--path-format`, and then request the other.  However, that can't be
done with `git repo` and `--path-format`.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA