From 52bb0046c0bf0e50598c513e43b76d593f2cbbff Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 4 Nov 2009 16:26:03 +0100 Subject: 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 --- lib/git/diff.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/git/diff.py') 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 -- cgit v1.2.1