diff options
author | Paul Sowden <paul@idontsmoke.co.uk> | 2008-11-21 23:06:19 -0800 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2008-12-15 14:15:06 -0500 |
commit | 5da34fddda2ea6de19ecf04efd75e323c4bb41e4 (patch) | |
tree | d9f615db8feff57cd1e5d4ac0a42d81001bde4f2 /lib/git/diff.py | |
parent | 753e908dcea03cf9962cf45d3965cf93b0d30d94 (diff) | |
download | gitpython-5da34fddda2ea6de19ecf04efd75e323c4bb41e4.tar.gz |
add support for parsing rename info to the diff parser
Currently the parsed headers are just ignored but I'll add them to the Diff object in a future commit
(cherry picked from commit 711b655f29b42821c51be8e592143c7db31ed140)
Diffstat (limited to 'lib/git/diff.py')
-rw-r--r-- | lib/git/diff.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/git/diff.py b/lib/git/diff.py index 28ebda01..626c4df9 100644 --- a/lib/git/diff.py +++ b/lib/git/diff.py @@ -39,8 +39,11 @@ class Diff(object): diff_header = re.compile(r""" #^diff[ ]--git [ ]a/(?P<a_path>\S+)[ ]b/(?P<b_path>\S+)\n - (?:^old[ ]mode[ ](?P<old_mode>\d+)(?:\n|$))? - (?:^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? + (?:^similarity[ ]index[ ](?P<similarity_index>\d+)%\n + ^rename[ ]from[ ](?P<rename_from>\S+)\n + ^rename[ ]to[ ](?P<rename_to>\S+)(?:\n|$))? + (?:^old[ ]mode[ ](?P<old_mode>\d+)\n + ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))? (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))? (?:^index[ ](?P<a_commit>[0-9A-Fa-f]+) @@ -50,7 +53,8 @@ class Diff(object): for diff in ('\n' + text).split('\ndiff --git')[1:]: header = diff_header(diff) - a_path, b_path, old_mode, new_mode, new_file_mode, deleted_file_mode, \ + a_path, b_path, similarity_index, rename_from, rename_to, \ + old_mode, new_mode, new_file_mode, deleted_file_mode, \ a_commit, b_commit, b_mode = header.groups() new_file, deleted_file = bool(new_file_mode), bool(deleted_file_mode) |