File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ def work_tree_supported(self):
186186 True if not running in WSL mode or path is a local drive
187187 False if the working tree is no local drive in WSL mode.
188188 """
189- return not self ._git_wsl or self . _git_tree and self ._git_tree [ 1 ] == ':'
189+ return not self ._git_wsl or path . is_translatable_to_wsl ( self ._git_tree )
190190
191191 def translate_path_to_wsl (self , filename ):
192192 """Translate filename to a WSL compatible unix path on demand.
Original file line number Diff line number Diff line change 11import os .path
2+ import re
23
34try :
45 from nt import _getfinalpathname
@@ -93,6 +94,13 @@ def split_work_tree(file_path):
9394 return (None , None )
9495
9596
97+ def is_translatable_to_wsl (path ):
98+ return path and (
99+ path .startswith ('\\ \\ wsl.localhost\\ ' )
100+ or not path .startswith ('\\ \\ ' )
101+ )
102+
103+
96104def translate_to_wsl (path ):
97105 """Translate a windows path to unix path for WSL.
98106
@@ -113,7 +121,10 @@ def translate_to_wsl(path):
113121 Raises:
114122 FileNotFoundError: if path is an UNC path.
115123 """
116- if path .startswith ('\\ \\ ' ):
124+ # remove UNC prefix for paths pointing to WSL environment
125+ if path .startswith ('\\ \\ wsl.localhost\\ ' ):
126+ wsl_path = re .sub (r"\\\\wsl\.localhost\\[^\\]*" , "" , path )
127+ elif path .startswith ('\\ \\ ' ):
117128 raise FileNotFoundError ('UNC paths are not supported by WSL!' )
118129 wsl_path = path .replace ('\\ ' , '/' )
119130 if wsl_path [1 :3 ] == ':/' :
You can’t perform that action at this time.
0 commit comments