diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc index 4c0cc82cf2..0902dff3fd 100644 --- a/winsup/cygwin/msys2_path_conv.cc +++ b/winsup/cygwin/msys2_path_conv.cc @@ -358,6 +358,18 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en return NONE; } + /* + * Discern between Git's `:`, SCP's `:` pattern + * (which is not a path list but may naïvely look like one) on the one + * hand, and path lists starting with `/`, `./` or `../` + * on the other hand. + */ + bool potential_path_list = *it == '/' || + (*it == '.' && + (it[1] == ':' || it[1] == '/' || + (it[1] == '.' && + (it[2] == ':' || it[2] == '/')))); + /* * Prevent Git's :file.txt and :/message syntax from beeing modified. */ @@ -383,7 +395,7 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en goto skip_p2w; // Leave Git's :./name syntax alone - if (it + 1 < end && it[1] == '.') { + if (!potential_path_list && it + 1 < end && it[1] == '.') { if (it + 2 < end && it[2] == '/') goto skip_p2w; if (it + 3 < end && it[2] == '.' && it[3] == '/')