Skip to content

Commit e405c61

Browse files
committed
Issue #1: Fixes parsing of lines that shouldn't exist in default diffs
1 parent a949ae8 commit e405c61

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

tests/test_patch.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,16 +794,9 @@ def test_diff_default_blah(self):
794794
changes=[
795795
(1, None, 'The Way that can be told of is not the eternal Way;'),
796796
(2, None, 'The name that can be named is not the eternal name.'),
797-
(3, 1, 'The Nameless is the origin of Heaven and Earth;'),
798797
(4, None, 'The Named is the mother of all things.'),
799798
(None, 2, 'The named is the mother of all things.'),
800799
(None, 3, ''),
801-
(5, 4, 'Therefore let there always be non-being,'),
802-
(6, 5, ' so we may see their subtlety,'),
803-
(7, 6, 'And let there always be being,'),
804-
(9, 8, 'The two are the same,'),
805-
(10, 9, 'But after they are produced,'),
806-
(11, 10, ' they have different names.'),
807800
(None, 11, 'They both may be called deep and profound.'),
808801
(None, 12, 'Deeper and more profound,'),
809802
(None, 13, 'The door of all subtleties!')],

whatthepatch/patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,10 @@ def parse_default_diff(text):
512512
kind = c.group(1)
513513
line = c.group(2)
514514

515-
if kind == '<':# and r != old_len:
515+
if kind == '<' and (r != old_len or r == 0):
516516
changes.append((old + r, None, line))
517517
r += 1
518-
elif kind == '>':# and i != new_len:
518+
elif kind == '>' and (i != new_len or i == 0):
519519
changes.append((None, new + i, line))
520520
i += 1
521521

0 commit comments

Comments
 (0)