diff options
-rw-r--r-- | lib/git/diff.py | 16 | ||||
-rw-r--r-- | test/git/test_diff.py | 2 |
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 |