diff options
author | George Hickman <george@ghickman.co.uk> | 2017-03-06 16:17:47 +0000 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2017-03-07 21:23:38 +0100 |
commit | a0788e0be3164acd65e3bc4b5bc1b51179b967ce (patch) | |
tree | 9390b5da06b79c9abfbaaf9efaeefb5b19c010d0 /git/repo/base.py | |
parent | 830070d7ed09d6eaa4bcaa84ab46c06c8fff33d8 (diff) | |
download | gitpython-a0788e0be3164acd65e3bc4b5bc1b51179b967ce.tar.gz |
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.
Diffstat (limited to 'git/repo/base.py')
-rw-r--r-- | git/repo/base.py | 13 |
1 files changed, 8 insertions, 5 deletions
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), |