aboutsummaryrefslogtreecommitdiff
path: root/lib/git/diff.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-11-04 16:26:03 +0100
committerSebastian Thiel <byronimo@gmail.com>2009-11-04 16:26:03 +0100
commit52bb0046c0bf0e50598c513e43b76d593f2cbbff (patch)
treea02972d19613131d428c98dec0a1d414b84c5274 /lib/git/diff.py
parentf41d42ee7e264ce2fc32cea555e5f666fa1b1fe9 (diff)
downloadGitPython-52bb0046c0bf0e50598c513e43b76d593f2cbbff.tar.gz
GitPython-52bb0046c0bf0e50598c513e43b76d593f2cbbff.zip
added query for 'M' modified diffs to DiffIndex including test. The latter one was made faster by reducing the amount of permutations to the minimal value
Diffstat (limited to 'lib/git/diff.py')
-rw-r--r--lib/git/diff.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/git/diff.py b/lib/git/diff.py
index 9a826630..a43d3725 100644
--- a/lib/git/diff.py
+++ b/lib/git/diff.py
@@ -114,8 +114,8 @@ class DiffIndex(list):
# A = Added
# D = Deleted
# R = Renamed
- # NOTE: 'Modified' mode is impllied as it wouldn't be listed as a diff otherwise
- change_type = ("A", "D", "R")
+ # M = modified
+ change_type = ("A", "D", "R", "M")
def iter_change_type(self, change_type):
@@ -124,7 +124,15 @@ class DiffIndex(list):
iterator yieling Diff instances that match the given change_type
``change_type``
- Member of DiffIndex.change_type
+ Member of DiffIndex.change_type, namely
+
+ 'A' for added paths
+
+ 'D' for deleted paths
+
+ 'R' for renamed paths
+
+ 'M' for paths with modified data
"""
if change_type not in self.change_type:
raise ValueError( "Invalid change type: %s" % change_type )
@@ -136,6 +144,8 @@ class DiffIndex(list):
yield diff
elif change_type == "R" and diff.renamed:
yield diff
+ elif change_type == "M" and diff.a_blob and diff.b_blob and diff.a_blob != diff.b_blob:
+ yield diff
# END for each diff