@@ -73,9 +73,9 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
7373 args .append ("--abbrev=40" ) # we need full shas
7474 args .append ("--full-index" ) # get full index paths, not only filenames
7575
76+ args .append ("-M" ) # check for renames, in both formats
7677 if create_patch :
7778 args .append ("-p" )
78- args .append ("-M" ) # check for renames
7979 else :
8080 args .append ("--raw" )
8181
@@ -318,14 +318,11 @@ def _index_from_patch_format(cls, repo, stream):
318318 @classmethod
319319 def _index_from_raw_format (cls , repo , stream ):
320320 """Create a new DiffIndex from the given stream which must be in raw format.
321- :note:
322- This format is inherently incapable of detecting renames, hence we only
323- modify, delete and add files
324321 :return: git.DiffIndex"""
325322 # handles
326323 # :100644 100644 687099101... 37c5e30c8... M .gitignore
327324 index = DiffIndex ()
328- for line in stream :
325+ for line in stream . readlines () :
329326 line = line .decode (defenc )
330327 if not line .startswith (":" ):
331328 continue
@@ -336,6 +333,8 @@ def _index_from_raw_format(cls, repo, stream):
336333 b_path = path
337334 deleted_file = False
338335 new_file = False
336+ rename_from = None
337+ rename_to = None
339338
340339 # NOTE: We cannot conclude from the existance of a blob to change type
341340 # as diffs with the working do not have blobs yet
@@ -345,10 +344,13 @@ def _index_from_raw_format(cls, repo, stream):
345344 elif change_type == 'A' :
346345 a_blob_id = None
347346 new_file = True
347+ elif change_type [0 ] == 'R' : # parses RXXX, where XXX is a confidence value
348+ a_path , b_path = path .split ('\t ' , 1 )
349+ rename_from , rename_to = a_path , b_path
348350 # END add/remove handling
349351
350352 diff = Diff (repo , a_path , b_path , a_blob_id , b_blob_id , old_mode , new_mode ,
351- new_file , deleted_file , None , None , '' )
353+ new_file , deleted_file , rename_from , rename_to , '' )
352354 index .append (diff )
353355 # END for each line
354356
0 commit comments