From 029b82807c3af7b1d5474652b8f02d34620b8b7c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 19 May 2018 23:02:49 +0530 Subject: [PATCH] Ignore \ prefixed lines when parsing patches --- kittens/diff/patch.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kittens/diff/patch.py b/kittens/diff/patch.py index 4825a5241..6573d85d4 100644 --- a/kittens/diff/patch.py +++ b/kittens/diff/patch.py @@ -174,20 +174,23 @@ class Patch: def parse_patch(raw): all_hunks = [] + current_hunk = None for line in raw.splitlines(): if line.startswith('@@ '): current_hunk = parse_hunk_header(line) all_hunks.append(current_hunk) else: - if not all_hunks: + if current_hunk is None: continue q = line[0] if q == '+': - all_hunks[-1].add_line() + current_hunk.add_line() elif q == '-': - all_hunks[-1].remove_line() + current_hunk.remove_line() + elif q == '\\': + continue else: - all_hunks[-1].context_line() + current_hunk.context_line() for h in all_hunks: h.finalize() return Patch(all_hunks)