@@ -238,11 +238,8 @@ def test_clone_from_keeps_env(self, rw_dir):
238238 @with_rw_directory
239239 def test_clone_from_drive_rooted_destination (self , rw_dir ):
240240 original_repo = Repo .init (osp .join (rw_dir , "repo" ))
241-
242- # Drive-rooted paths resolve on the current drive. Keep the destination
243- # there even when the system temporary directory uses another drive.
244- with tempfile .TemporaryDirectory (dir = os .getcwd ()) as destination_root :
245- destination = osp .join (destination_root , "clone" )
241+ with cwd (rw_dir ):
242+ destination = osp .join (rw_dir , "clone" )
246243 _drive , rooted_destination = osp .splitdrive (destination )
247244
248245 cloned = Repo .clone_from (original_repo .git_dir , rooted_destination )
@@ -1240,21 +1237,22 @@ def test_git_work_tree_dotgit_relative(self):
12401237 @pytest .mark .skipif (os .name != "nt" , reason = "Specifically for Windows drive-rooted paths." )
12411238 @with_rw_directory
12421239 def test_linked_worktree_drive_rooted_gitdir_file (self , rw_dir ):
1243- main_repo = self .rorepo .clone (join_path_native (rw_dir , "main_repo" ))
1244- branch = main_repo .create_head ("drive-rooted-worktree" )
1245- worktree_path = join_path_native (rw_dir , "worktree_repo" )
1246- main_repo .git .worktree ("add" , worktree_path , branch .name )
1247-
1248- linked_repo = Repo (worktree_path )
1249- gitdir_file = osp .join (linked_repo .git_dir , "gitdir" )
1250- worktree_gitfile = osp .join (worktree_path , ".git" )
1251- _drive , rooted_worktree_gitfile = osp .splitdrive (worktree_gitfile )
1252- with open (gitdir_file , "w" ) as stream :
1253- stream .write (rooted_worktree_gitfile )
1254-
1255- reopened_repo = Repo (linked_repo .git_dir )
1256-
1257- assert osp .samefile (reopened_repo .working_tree_dir , worktree_path )
1240+ with cwd (rw_dir ):
1241+ main_repo = self .rorepo .clone (join_path_native (rw_dir , "main_repo" ))
1242+ branch = main_repo .create_head ("drive-rooted-worktree" )
1243+ worktree_path = join_path_native (rw_dir , "worktree_repo" )
1244+ main_repo .git .worktree ("add" , worktree_path , branch .name )
1245+
1246+ linked_repo = Repo (worktree_path )
1247+ gitdir_file = osp .join (linked_repo .git_dir , "gitdir" )
1248+ worktree_gitfile = osp .join (worktree_path , ".git" )
1249+ _drive , rooted_worktree_gitfile = osp .splitdrive (worktree_gitfile )
1250+ with open (gitdir_file , "w" ) as stream :
1251+ stream .write (rooted_worktree_gitfile )
1252+
1253+ reopened_repo = Repo (linked_repo .git_dir )
1254+
1255+ assert osp .samefile (reopened_repo .working_tree_dir , worktree_path )
12581256
12591257 @with_rw_directory
12601258 def test_git_work_tree_env (self , rw_dir ):
0 commit comments