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

Fix pathconv issues related to relative paths in path lists #213

Conversation

ReinhardBiegelIntech
Copy link

Implementation associated with testsuite changes here: msys2/msys2-tests#67

Only tested in testsuite yet.

@dscho

@reneparis
Copy link

@lazka

Comment on lines 361 to 372
/*
* Discern between Git's `<rev>:<path>`, SCP's `<host>:<path>` pattern
* (which is not a path list but may naïvely look like one) on the one
* hand, and path lists starting with `/<path>`, `./<path>` or `../<path>`
* on the other hand.
*/
bool potential_path_list = *it == '/' ||
(*it == '.' &&
(it[1] == ':' || it[1] == '/' ||
(it[1] == '.' &&
(it[2] == ':' || it[2] == '/'))));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/*
* Discern between Git's `<rev>:<path>`, SCP's `<host>:<path>` pattern
* (which is not a path list but may naïvely look like one) on the one
* hand, and path lists starting with `/<path>`, `./<path>` or `../<path>`
* on the other hand.
*/
bool potential_path_list = *it == '/' ||
(*it == '.' &&
(it[1] == ':' || it[1] == '/' ||
(it[1] == '.' &&
(it[2] == ':' || it[2] == '/'))));
/*
* Discern between Git's `<rev>:<path>`, SCP's `<host>:<path>` pattern
* (which is not a path list but may naively look like one) on the one
* hand, and path lists starting with `/<path>`, `./<path>` or `../<path>`
* on the other hand.
*/
bool potential_path_list = *it == '/' ||
(*it == '.' &&
(it + 1 == end || it[1] == '\0' || it[1] == ':' || it[1] == '/' ||
(it[1] == '.' &&
(it + 2 == end || it[2] == '\0' || it[2] == ':' || it[2] == '/'))));
  • Watch for end-of-string / end of input.
  • This file mostly doesn't use tabs.
  • Let's not introduce a character ï that isn't encoded the same in iso-latin1 and utf-8 (there are no others in this file yet).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ReinhardBiegelIntech, what do you think?

(This replaces a deleted comment which tagged @ reneparis. Apologies, René.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked your code and agree on your suggestions - so let's wait for reinhard (currently on vacation) to implement it as soon as he's back.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback, @bustercopley. Suggestions look good to me, so I updated the PR accordingly. Also committed to test suite.

As the changes affect code originally written bei @dscho, I'd also like to get his feedback here.

dscho and others added 3 commits July 2, 2024 15:53
…nvironment variables to Windows form for native Win32 applications.

When we fixed MSYS2's automatic Unix <-> Windows path conversion to
identify and skip Git-style `<rev>:<path>` arguments (and incidentally
also scp-style `<host>:<path>` ones), we assumed that path lists
containing relative paths would be a rare scenario.

My, was this assumption wrong!

Let's add another heuristic that detects absolute paths at the beginning
of path lists, and relative ones starting with either `./` or `../`,
neither of which match those Git-style nor scp-style arguments, and then
prevent the detection of the latter style from kicking in.

This addresses msys2#208

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
…ables assigned on command line

This restores parts of the previous behavior of path_conv, fixing an
issue where the paths of the path list in `VARIABLE=.:../foo/bar
./my-script.sh` weren't convertet to windows paths. The path conversion
was skipped due to interpretation as a Git style reference. The Git
detection is now excluded for this kind of variable assignments.
Suggested-by: Richard Copley <buster@buster.me.uk>
@ReinhardBiegelIntech ReinhardBiegelIntech changed the base branch from msys2-3.4.10 to msys2-3.5.3 July 2, 2024 13:55
@ReinhardBiegelIntech
Copy link
Author

Seems like this doesn't match any maintainer's idea of how to address #208, so im closing here.

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.

4 participants