Skip to content

Commit

Permalink
fixup! Add functionality for converting UNIX paths in arguments and e…
Browse files Browse the repository at this point in the history
…nvironment variables to Windows form for native Win32 applications.

Let's prevent scp-style arguments from being mangled by MSYS2's path
conversion.

An argument like `me@example.com:/tmp/` is not something we should convert
into a Windows path; Use the absence of a slash before the colon as a
tell-tale that it is *not* a POSIX path list (exception: if the part
left of the colon is `.` or `..`).

This addresses the expectations of the following test cases in the test
suite of https://github.com/git/git/tree/v2.43.0:

-t5516.8 fetch with insteadOf
-t5516.16 push with insteadOf
-t5516.17 push with pushInsteadOf
-t5602.2 clone calls git upload-pack unqualified with no -u option
-t5602.3 clone calls specified git upload-pack with -u option
-t5603.31 clone of host:/ goes to host (non-bare)
-t5603.35 clone of user@host:/ goes to host (non-bare)
-t5813.81 full paths still work

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Dec 17, 2023
1 parent 9553100 commit 5a2ac07
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions winsup/cygwin/msys2_path_conv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en

int starts_with_minus = 0;
int starts_with_minus_alpha = 0;
int only_dots = *it == '.';
int has_slashes = 0;
if (*it == '-') {
starts_with_minus = 1;
it += 1;
Expand Down Expand Up @@ -505,11 +507,17 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en
if (ch == '/' && *(it2 + 1) == '/') {
return URL;
} else {
if (!only_dots && !has_slashes)
goto skip_p2w;
return POSIX_PATH_LIST;
}
} else if (memchr(it2, '=', end - it2) == NULL) {
return SIMPLE_WINDOWS_PATH;
}
} else if (ch != '.') {
only_dots = 0;
if (ch == '/' || ch == '\\')
has_slashes = 1;
}
}

Expand Down

0 comments on commit 5a2ac07

Please sign in to comment.