Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8dc98aa

Browse files
author
Patrick Pfeifer
committed
detect renames in "git diff --raw" output
potentiallyfixes#36
1 parentcd72d78 commit8dc98aa

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎git/diff.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,21 +310,24 @@ def _index_from_patch_format(cls, repo, stream):
310310
@classmethod
311311
def_index_from_raw_format(cls,repo,stream):
312312
"""Create a new DiffIndex from the given stream which must be in raw format.
313-
:note:
314-
This format is inherently incapable of detecting renames, hence we only
315-
modify, delete and add files
316313
:return: git.DiffIndex"""
317314
# handles
318315
# :100644 100644 6870991011cc8d9853a7a8a6f02061512c6a8190 37c5e30c879213e9ae83b21e9d11e55fc20c54b7 M.gitignore
316+
# or
317+
# :100644 100644 4aab7ea753e2867dd464f2a50dd266d426ddc8c8 4aab7ea753e2867dd464f2a50dd266d426ddc8c8 R100 src/bootstrap/package.jsonpackage.json
319318
index=DiffIndex()
320319
forlineinstream:
321320
ifnotline.startswith(":"):
322321
continue
323322
# END its not a valid diff line
324323
old_mode,new_mode,a_blob_id,b_blob_id,change_type,path=line[1:].split(None,5)
325324
path=path.strip()
326-
a_path=path
327-
b_path=path
325+
ifchange_type[0]!='R':
326+
a_path=b_path=path
327+
rename_from=rename_to=None
328+
else:
329+
a_path,b_path=path.split('\t')
330+
rename_from,rename_to=a_path,b_path
328331
deleted_file=False
329332
new_file=False
330333

@@ -339,7 +342,7 @@ def _index_from_raw_format(cls, repo, stream):
339342
# END add/remove handling
340343

341344
diff=Diff(repo,a_path,b_path,a_blob_id,b_blob_id,old_mode,new_mode,
342-
new_file,deleted_file,None,None,'')
345+
new_file,deleted_file,rename_from,rename_to,'')
343346
index.append(diff)
344347
# END for each line
345348

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp