Subject: Re: [PATCH] rev-parse: add option for absolute or relative path formatting

From: Jonathan Nieder <[email-masked]>
Date: Thu, 5 Nov 2020 16:51:10 -0800

brian m. carlson wrote:
> On 2020-11-04 at 22:16:59, Jonathan Nieder wrote:
> > brian m. carlson wrote:

>>> This impetus for this patch is Git LFS, which is written in Go.  Go
>>> lacks a cross-platform way to canonicalize paths in the same way that
>>> Git does, so when Git produces relative paths, such as in some cases
>>> with --git-common-dir, we end up with problems when users are doing
>>> things with unusual paths on Windows, such as when using SUBST
[...]
>> Can you describe the user-facing symptom?  While reviewing
>> https://lore.kernel.org/git/[email-masked]/
>> I'm trying to understand the motivation and I'm getting stuck at
>> trying to understand the basics of the problem being solved.
[...]
> The goal is to resolve paths the way Git does and allow verify that a
> path is within the repository.

Ah, thank you.  So if I am understanding the above and [1] correctly,
this means:

- when a path is within a repository, converting it to a path relative
  to the repository root

- when a path is not within a repository, learning so

and that making relative paths with ../../ portion that exits the
repository is *not* an important part of this use case (though it
could be useful for other things).

[...]
> This is also generally applicable for scripting, where realpath(1) is
> not always available (e.g., on macOS), but mostly this is here to make
> Windows work more nicely, since it has more complex path functionality.

Thanks much.  I think this tells me enough to understand the series.

Sincerely,
Jonathan

[1] https://github.com/git-lfs/git-lfs/issues/4012 --- thanks to Emily
for the pointer in [2].
[2] https://lore.kernel.org/git/[email-masked]/