[diffoscope] 03/03: Fix behaviour for max-diff-block-limit=1 and don't report when 0 lines are removed

Ximin Luo infinity0 at debian.org
Tue Sep 6 20:58:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository diffoscope.

commit 9cb0b945272f3e39001d2d4157dc43debb90db98
Author: Ximin Luo <infinity0 at debian.org>
Date:   Tue Sep 6 22:33:40 2016 +0200

    Fix behaviour for max-diff-block-limit=1 and don't report when 0 lines are removed
---
 diffoscope/difference.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/diffoscope/difference.py b/diffoscope/difference.py
index 53faffc..6c63c72 100644
--- a/diffoscope/difference.py
+++ b/diffoscope/difference.py
@@ -107,8 +107,12 @@ class DiffParser(object):
         else:
             raise ValueError('Unable to parse diff hunk: %s' % repr(line))
         self._diff.write(line)
-        if line[0] in ('-', '+') and line[0] == self._direction:
-            self._block_len += 1
+        if line[0] in ('-', '+'):
+            if line[0] == self._direction:
+                self._block_len += 1
+            else:
+                self._block_len = 1
+                self._direction = line[0]
             max_lines = Config.general.max_diff_block_lines
             if self._block_len >= max_lines:
                 return self.skip_block
@@ -119,7 +123,9 @@ class DiffParser(object):
 
     def skip_block(self, line):
         if self._remaining_hunk_lines == 0 or line[0] != self._direction:
-            self._diff.write('%s[ %d lines removed ]\n' % (self._direction, self._block_len - Config.general.max_diff_block_lines))
+            removed = self._block_len - Config.general.max_diff_block_lines
+            if removed:
+                self._diff.write('%s[ %d lines removed ]\n' % (self._direction, removed))
             return self.read_hunk(line)
         self._block_len += 1
         self._remaining_hunk_lines -= 1

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list