Skip to content

Commit

Permalink
Fixed consecutive lines with same blame info not appearing in blame.
Browse files Browse the repository at this point in the history
This fixes a bug when parsing blame -p output: Full commit info headers
only appear for the first line from a particular commit, but other lines
were ignored as the blame info dict was reset after each line.

This patch handles both multiple consecutive lines from a commit and
interleaved lines from multiple commits.
  • Loading branch information
devnev authored and Byron committed Jul 18, 2011
1 parent d6d544f commit 1f6b8bf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions git/repo/base.py
Expand Up @@ -570,11 +570,14 @@ def blame(self, rev, file):
if self.re_hexsha_only.search(firstpart):
# handles
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 1 1 7 - indicates blame-data start
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 2 2
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 2 2 - indicates another line of blame with the same data
digits = parts[-1].split(" ")
if len(digits) == 3:
info = {'id': firstpart}
blames.append([None, []])
elif info['id'] != firstpart:
info = {'id': firstpart}
blames.append([commits.get(firstpart), []])
# END blame data initialization
else:
m = self.re_author_committer_start.search(firstpart)
Expand Down Expand Up @@ -622,7 +625,7 @@ def blame(self, rev, file):
text, = m.groups()
blames[-1][0] = c
blames[-1][1].append( text )
info = None
info = {'id': sha}
# END if we collected commit info
# END distinguish filename,summary,rest
# END distinguish author|committer vs filename,summary,rest
Expand Down

0 comments on commit 1f6b8bf

Please sign in to comment.