Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73ab287

Browse files
committed
Split lines by new line characters
Opt to split lines by the new line character instead of letting `splitlines()` do this. This helps catch the issue when there are special characters in the line, particular the commit summary section.
1 parent 7a8f96c commit 73ab287

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

git/repo/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,10 +682,12 @@ def blame_incremental(self, rev, file, **kwargs):
682682
data = self.git.blame(rev, '--', file, p=True, incremental=True, stdout_as_string=False, **kwargs)
683683
commits = dict()
684684

685-
stream = iter(data.splitlines())
685+
stream = iter(data.split(b'\n'))
686686
while True:
687687
line = next(stream) # when exhausted, casues a StopIteration, terminating this function
688-
688+
if line.strip() == '':
689+
# Skip over empty lines
690+
continue
689691
hexsha, orig_lineno, lineno, num_lines = line.split()
690692
lineno = int(lineno)
691693
num_lines = int(num_lines)

git/test/fixtures/blame_incremental

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ committer Sebastian Thiel
77
committer-mail <[email protected]>
88
committer-time 1270634931
99
committer-tz +0200
10-
summary Used this release for a first beta of the 0.2 branch of development
10+
summary Used this release for a first beta of the 0.2 branch of development
1111
previous 501bf602abea7d21c3dbb409b435976e92033145 AUTHORS
1212
filename AUTHORS
1313
82b8902e033430000481eb355733cd7065342037 14 14 1

0 commit comments

Comments
 (0)