Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion winsup/cygwin/msys2_path_conv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<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] == '/'))));

/*
* Prevent Git's :file.txt and :/message syntax from beeing modified.
*/
Expand All @@ -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 <rev>:./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] == '/')
Expand Down