summaryrefslogtreecommitdiff
path: root/git/diff.py
diff options
context:
space:
mode:
authorPatrick Pfeifer <p2000@mailinator.com>2012-06-16 00:16:25 +0200
committerPatrick Pfeifer <p2000@mailinator.com>2012-06-16 00:20:08 +0200
commit8dc98aa77f93f10cfac27c8477fa04a5ce506829 (patch)
treec54f5b99f2d865dd6f48911ec2b0ce69b447e014 /git/diff.py
parentcd72d78e79271f0f9025984fb2d9a6c5b4dba4de (diff)
downloadgitpython-8dc98aa77f93f10cfac27c8477fa04a5ce506829.tar.gz
detect renames in "git diff --raw" output
potentially fixes https://github.com/gitpython-developers/GitPython/issues/36
Diffstat (limited to 'git/diff.py')
-rw-r--r--git/diff.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/git/diff.py b/git/diff.py
index d1c6c0ac..93ef514f 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -310,12 +310,11 @@ class Diff(object):
@classmethod
def _index_from_raw_format(cls, repo, stream):
"""Create a new DiffIndex from the given stream which must be in raw format.
- :note:
- This format is inherently incapable of detecting renames, hence we only
- modify, delete and add files
:return: git.DiffIndex"""
# handles
# :100644 100644 6870991011cc8d9853a7a8a6f02061512c6a8190 37c5e30c879213e9ae83b21e9d11e55fc20c54b7 M .gitignore
+ # or
+ # :100644 100644 4aab7ea753e2867dd464f2a50dd266d426ddc8c8 4aab7ea753e2867dd464f2a50dd266d426ddc8c8 R100 src/bootstrap/package.json package.json
index = DiffIndex()
for line in stream:
if not line.startswith(":"):
@@ -323,8 +322,12 @@ class Diff(object):
# END its not a valid diff line
old_mode, new_mode, a_blob_id, b_blob_id, change_type, path = line[1:].split(None, 5)
path = path.strip()
- a_path = path
- b_path = path
+ if change_type[0] != 'R':
+ a_path = b_path = path
+ rename_from = rename_to = None
+ else:
+ a_path, b_path = path.split('\t')
+ rename_from, rename_to = a_path, b_path
deleted_file = False
new_file = False
@@ -339,7 +342,7 @@ class Diff(object):
# END add/remove handling
diff = Diff(repo, a_path, b_path, a_blob_id, b_blob_id, old_mode, new_mode,
- new_file, deleted_file, None, None, '')
+ new_file, deleted_file, rename_from, rename_to, '')
index.append(diff)
# END for each line