File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -653,7 +653,7 @@ def _to_relative_path(self, path: PathLike) -> PathLike:
653653            return  path 
654654        if  self .repo .bare :
655655            raise  InvalidGitRepositoryError ("require non-bare repository" )
656-         if  not  str (path ).startswith (str (self .repo .working_tree_dir )):
656+         if  not  osp . normpath ( str (path ) ).startswith (str (self .repo .working_tree_dir )):
657657            raise  ValueError ("Absolute path %r is not in git repository at %r"  %  (path , self .repo .working_tree_dir ))
658658        return  os .path .relpath (path , self .repo .working_tree_dir )
659659
Original file line number Diff line number Diff line change @@ -1181,6 +1181,18 @@ def test_index_add_pathlike(self, rw_repo):
11811181
11821182        rw_repo .index .add (file )
11831183
1184+     @with_rw_repo ("HEAD" ) 
1185+     def  test_index_add_non_normalized_path (self , rw_repo ):
1186+         git_dir  =  Path (rw_repo .git_dir )
1187+ 
1188+         file  =  git_dir  /  "file.txt" 
1189+         file .touch ()
1190+         non_normalized_path  =  file .as_posix ()
1191+         if  os .name  !=  "nt" :
1192+             non_normalized_path  =  "/"  +  non_normalized_path [1 :].replace ("/" , "//" )
1193+ 
1194+         rw_repo .index .add (non_normalized_path )
1195+ 
11841196
11851197class  TestIndexUtils :
11861198    @pytest .mark .parametrize ("file_path_type" , [str , Path ]) 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments