summaryrefslogtreecommitdiff
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
parentf41d42ee7e264ce2fc32cea555e5f666fa1b1fe9 (diff)
downloadgitpython-52bb0046c0bf0e50598c513e43b76d593f2cbbff.tar.gz
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
-rw-r--r--lib/git/diff.py16
-rw-r--r--test/git/test_diff.py2
2 files changed, 14 insertions, 4 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
diff --git a/test/git/test_diff.py b/test/git/test_diff.py
index ead231e5..9335aced 100644
--- a/test/git/test_diff.py
+++ b/test/git/test_diff.py
@@ -41,7 +41,7 @@ class TestDiff(TestBase):
def test_diff_interface(self):
# test a few variations of the main diff routine
assertion_map = dict()
- for i, commit in enumerate(self.rorepo.iter_commits('0.1.6', max_count=10)):
+ for i, commit in enumerate(self.rorepo.iter_commits('0.1.6', max_count=2)):
diff_item = commit
if i%2 == 0:
diff_item = commit.tree