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 @@ -617,11 +617,11 @@ def _preprocess_add_items(
617617        paths  =  []
618618        entries  =  []
619619        # if it is a string put in list 
620-         if  isinstance (items , str ):
620+         if  isinstance (items , ( str ,  os . PathLike ) ):
621621            items  =  [items ]
622622
623623        for  item  in  items :
624-             if  isinstance (item , str ):
624+             if  isinstance (item , ( str ,  os . PathLike ) ):
625625                paths .append (self ._to_relative_path (item ))
626626            elif  isinstance (item , (Blob , Submodule )):
627627                entries .append (BaseIndexEntry .from_blob (item ))
Original file line number Diff line number Diff line change 3737import  os .path  as  osp 
3838from  git .cmd  import  Git 
3939
40+ from  pathlib  import  Path 
41+ 
4042HOOKS_SHEBANG  =  "#!/usr/bin/env sh\n " 
4143
4244is_win_without_bash  =  is_win  and  not  shutil .which ("bash.exe" )
@@ -943,3 +945,12 @@ def test_commit_msg_hook_fail(self, rw_repo):
943945                assert  str (err )
944946        else :
945947            raise  AssertionError ("Should have caught a HookExecutionError" )
948+ 
949+     @with_rw_repo ('HEAD' ) 
950+     def  test_index_add_pathlike (self , rw_repo ):
951+         git_dir  =  Path (rw_repo .git_dir )
952+ 
953+         file  =  git_dir  /  "file.txt" 
954+         file .touch ()
955+ 
956+         rw_repo .index .add (file )
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments