From dba012d3e739305f4c08068a330cfe5db885dad6 Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Wed, 18 Feb 2015 11:07:17 +0000
Subject: [PATCH 46/N] fixup! Add functionality for converting UNIX paths in
 arguments and environment variables to Windows form for native Win32
 applications.

Do not let MSYS2's path conversion mistake arguments starting with '@@'
for being paths.

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

-t1508.1 setup
-t1508.2 HEAD = refs/heads/new-branch
-t1508.3 @{1} = new-one
-t1508.4 HEAD@{1} = new-one
-t1508.5 @{now} = new-two
-t1508.6 HEAD@{now} = new-two
-t1508.7 @{-1} = refs/heads/old-branch
-t1508.8 @{-1}@{0} = old-two
-t1508.9 @{-1}@{1} = old-one
-t1508.10 @{u} = refs/heads/upstream-branch
-t1508.11 HEAD@{u} = refs/heads/upstream-branch
-t1508.12 @{u}@{1} = upstream-one
-t1508.13 @{-1}@{u} = refs/heads/main
-t1508.14 @{-1}@{u}@{1} = main-one
-t1508.15 @ = new-two
-t1508.16 @@{u} = refs/heads/upstream-branch
-t1508.17 @@/at-test = refs/heads/@@/at-test
-t1508.18 @at-test = refs/heads/@at-test
-t1508.24 HEAD@{3} = old-two
-t1508.26 switch to old-branch
-t1508.27 HEAD = refs/heads/old-branch
-t1508.28 HEAD@{1} = new-two
-t1508.29 @{1} = old-one

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 winsup/cygwin/msys2_path_conv.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/winsup/cygwin/msys2_path_conv.cc b/winsup/cygwin/msys2_path_conv.cc
index 0ac47f0..0976cf9 100644
--- a/winsup/cygwin/msys2_path_conv.cc
+++ b/winsup/cygwin/msys2_path_conv.cc
@@ -389,6 +389,10 @@ skip_p2w:
                     goto skip_p2w;
             }
             break;
+        case '@':
+            // Paths do not contain '@@'
+            if (it + 1 < end && it[1] == '@')
+                goto skip_p2w;
         }
         ++it;
     }
