Skip to content

Split lines by new line characters #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,12 @@ def blame_incremental(self, rev, file, **kwargs):
data = self.git.blame(rev, '--', file, p=True, incremental=True, stdout_as_string=False, **kwargs)
commits = dict()

stream = iter(data.splitlines())
stream = iter(data.split(b'\n'))
while True:
line = next(stream) # when exhausted, casues a StopIteration, terminating this function

if line.strip() == '' or line.strip() == b'':
# Skip over empty lines
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, this actually has nothing to do with the ^M chars in the fixture. It's because of this:

>>> s = 'foo\nbar\n'
>>> s.splitlines()
['foo', 'bar']
>>> s.split('\n')
['foo', 'bar', '']
               ^^

hexsha, orig_lineno, lineno, num_lines = line.split()
lineno = int(lineno)
num_lines = int(num_lines)
Expand Down
2 changes: 1 addition & 1 deletion git/test/fixtures/blame_incremental
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ committer Sebastian Thiel
committer-mail <[email protected]>
committer-time 1270634931
committer-tz +0200
summary Used this release for a first beta of the 0.2 branch of development
summary Used this release for a first beta of the 0.2 branch of development
previous 501bf602abea7d21c3dbb409b435976e92033145 AUTHORS
filename AUTHORS
82b8902e033430000481eb355733cd7065342037 14 14 1
Expand Down