From a0788e0be3164acd65e3bc4b5bc1b51179b967ce Mon Sep 17 00:00:00 2001 From: George Hickman Date: Mon, 6 Mar 2017 16:17:47 +0000 Subject: Ignore all lines of subsequent hunks until last one is found Git version 2.11.1+ introduced extra lines into the subsequent hunk sections for incremental blame output. The documentation notes that parsers of this output should ignore all lines between the start and end for robust parsing. --- git/repo/base.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'git/repo/base.py') diff --git a/git/repo/base.py b/git/repo/base.py index b889da71..fa9cb596 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -713,11 +713,14 @@ class Repo(object): committed_date=int(props[b'committer-time'])) commits[hexsha] = c else: - # Discard the next line (it's a filename end tag) - line = next(stream) - tag, value = line.split(b' ', 1) - assert tag == b'filename', 'Unexpected git blame output' - orig_filename = value + # Discard all lines until we find "filename" which is + # guaranteed to be the last line + while True: + line = next(stream) + tag, value = line.split(b' ', 1) + if tag == b'filename': + orig_filename = value + break yield BlameEntry(commits[hexsha], range(lineno, lineno + num_lines), -- cgit v1.2.3