Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-do the path interpolation support regarding RUNTIME_PREFIX #3472

Merged
merged 10 commits into from
Oct 15, 2021

Conversation

dscho
Copy link
Member

@dscho dscho commented Oct 15, 2021

For quite some time, Git for Windows supported config settings referring to a path that is relative to the location where Git is installed (the so-called "RUNTIME_PREFIX"). For example, setting http.sslCAInfo to /ssl/certs/ca-bundle.crt would make it expand automatically to C:\Program Files\Git\mingw64\ssl\certs\ca-bundle.crt.

When upstreaming this feature, it was decided that this was too limited (it only supported Windows, and since a leading slash indicates a valid absolute path on other platforms, could not be extended to span those platforms, too).

Instead, the value now needs to start with %(prefix)/ to be expanded in that way.

Let's take those patches, but also reinstate Git for Windows' original, now deprecated behavior. For good measure, let's print a warning that this has been deprecated.

dscho and others added 10 commits July 26, 2021 12:17
Originally, we refrained from adding a regression test in 7b6c649
(system_path(): Add prefix computation at runtime if RUNTIME_PREFIX set,
2008-08-10), and in 226c0dd (exec_cmd: RUNTIME_PREFIX on some POSIX
systems, 2018-04-10).

The reason was that it was deemed too tricky to test.

Turns out that it is not tricky to test at all: we simply create a
pseudo-root, copy the `git` executable into the `git/` subdirectory of
that pseudo-root, then copy a script into the `libexec/git-core/`
directory and expect that to be picked up.

As long as the trash directory is in a location where binaries can be
executed, this works.

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
In 395de25 (Expand ~ and ~user in core.excludesfile,
commit.template, 2009-11-17), the `user_path()` function was refactored
into the `expand_user_path()`. During that refactoring, the `buf`
parameter was lost, but the code comment above said function still talks
about it. Let's remove that stale part of the comment.

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
The `real_home` parameter only has an effect when expanding paths
starting with `~/`, not when expanding paths starting with `~<user>/`.
Let's make that clear.

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
It is not immediately clear what `expand_user_path()` means, so let's
rename it to `interpolate_path()`. This also opens the path for
interpolating more than just a home directory.

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
…efix

Ever since Git learned to detect its install location at runtime, there
was the slightly awkward problem that it was impossible to specify paths
relative to said location.

For example, if a version of Git was shipped with custom SSL
certificates to use, there was no portable way to specify
`http.sslCAInfo`.

In Git for Windows, the problem was "solved" for years by interpreting
paths starting with a slash as relative to the runtime prefix.

However, this is not correct: such paths _are_ legal on Windows, and
they are interpreted as absolute paths in the same drive as the current
directory.

After a lengthy discussion, and an even lengthier time to mull over the
problem and its best solution, and then more discussions, we eventually
decided to introduce support for the magic sequence `%(prefix)/`. If a
path starts with this, the remainder is interpreted as relative to the
detected (runtime) prefix. If built without runtime prefix support, Git
will simply interpolate the compiled-in prefix.

If a user _wants_ to specify a path starting with the magic sequence,
they can prefix the magic sequence with `./` and voilà, the path won't
be expanded.

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
This drops the original patch in preparation for merging the version
that made it upstream.

Signed-off-by: Johannes Schindelin <[email protected]>
This drops Git for Windows' version in preparation for merging the
version that made it upstream, followed by reinstating the
now-deprecated handling of a leading slash on Windows.

Signed-off-by: Johannes Schindelin <[email protected]>
Let's merge this topic early, as we will have to re-enable our previous
magic handling of a leading slash (but now with a deprecation warning).

Signed-off-by: Johannes Schindelin <[email protected]>
On Windows, an absolute POSIX path needs to be turned into a Windows
one. We used to interpret paths starting with a single `/` as relative
to the runtime-prefix, but now these need to be prefixed with
`%(prefix)/`. Let's warn for now, but still handle it.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho merged commit 3f28c5f into git-for-windows:main Oct 15, 2021
@dscho dscho deleted the expand-runtime-prefix branch October 15, 2021 13:12
@dscho dscho added this to the Next release milestone Oct 15, 2021
dscho added a commit to git-for-windows/build-extra that referenced this pull request Oct 15, 2021
Config settings referring to paths relative to where Git is installed
[now have to be marked via `%(prefix)/` instead of the now-deprecated
leading slash](git-for-windows/git#3472).

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this pull request Oct 15, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Oct 29, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Oct 30, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
@Stanzilla
Copy link

@dscho does this influence the git config includes like the tripple slashes in [includeIf "gitdir/i:///wsl$/Ubuntu/home/stan/projects/personal/**"]?

@dscho
Copy link
Member Author

dscho commented Nov 1, 2021

@dscho does this influence the git config includes like the tripple slashes in [includeIf "gitdir/i:///wsl$/Ubuntu/home/stan/projects/personal/**"]?

It should not. Does it?

@dscho
Copy link
Member Author

dscho commented Nov 1, 2021

I guess it does: it will probably complain, and the only solution might be to go from triple to double slashes (which should also work).

@Stanzilla
Copy link

@dscho Interesting, I'm asking because of this #2563 so it is expected to now work with only two?

@dscho
Copy link
Member Author

dscho commented Nov 1, 2021

Darn it. I fear that it might not be possible to specify this in a backwards-compatible way... :-( didn't think of that.

@Stanzilla
Copy link

Darn it. I fear that it might not be possible to specify this in a backwards-compatible way... :-( didn't think of that.

Okay let's say I migrate everything to the new version, how would the new format look like?

@dscho
Copy link
Member Author

dscho commented Nov 1, 2021

I think that it should work with two slashes, but it might not...

Maybe going forward, we'll keep treating three slashes as if they were two, and make it work with two slashes at the point when we drop the "treat paths starting with a slash as relative to git.exe's parent directory" patch.

dscho added a commit that referenced this pull request Nov 1, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Nov 1, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Nov 1, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Nov 2, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Nov 2, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Nov 2, 2021
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 7, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 10, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Jan 11, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Jan 11, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 11, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 11, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Jan 12, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Jan 12, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 12, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 12, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 12, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 12, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 12, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 13, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Jan 13, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Jan 13, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 15, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 15, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
git-for-windows-ci pushed a commit that referenced this pull request Jan 15, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Jan 16, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
dscho added a commit that referenced this pull request Jan 20, 2022
Re-do the path interpolation support regarding RUNTIME_PREFIX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants