File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -324,9 +324,9 @@ def _is_path_rooted(path: PathLike) -> bool:
324324 On POSIX, which has no drive concept, this simply distinguishes absolute
325325 paths such as ``/directory`` from relative paths such as ``directory``.
326326 """
327- _drive , tail = osp .splitdrive (os .fspath (path ))
327+ drive , tail = osp .splitdrive (os .fspath (path ))
328328 separators = (os .sep ,) if os .altsep is None else (os .sep , os .altsep )
329- return tail .startswith (separators )
329+ return tail .startswith (separators ) or bool ( drive ) and osp . isabs ( path )
330330
331331
332332def _to_relative_path (root : PathLike , path : PathLike ) -> str :
Original file line number Diff line number Diff line change @@ -1090,6 +1090,15 @@ class Mocked:
10901090 actual_path = index ._to_relative_path (path )
10911091 self .assertEqual (expected_path , actual_path )
10921092
1093+ @pytest .mark .skipif (sys .platform != "win32" , reason = "Specifically for Windows." )
1094+ def test__to_relative_path_windows_unc_share_root (self ):
1095+ for repo_root in [R"\\server\share" , R"\\?\UNC\server\share" ]:
1096+ with self .subTest (repo_root = repo_root ):
1097+ repo = mock .Mock (bare = False , git_dir = repo_root , working_tree_dir = repo_root )
1098+ index = IndexFile (repo )
1099+
1100+ self .assertEqual (index ._to_relative_path (repo_root ), "." )
1101+
10931102 @pytest .mark .skipif (sys .platform != "win32" , reason = "Specifically for Windows." )
10941103 @with_rw_directory
10951104 def test__to_relative_path_windows_path_kinds (self , rw_dir ):
You can’t perform that action at this time.
0 commit comments