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

Skip to content

Commit 1f6b8bf

Browse files
devnevByron
authored andcommitted
Fixed consecutive lines with same blame info not appearing in blame.
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.
1 parent d6d544f commit 1f6b8bf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

git/repo/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,14 @@ def blame(self, rev, file):
570570
if self.re_hexsha_only.search(firstpart):
571571
# handles
572572
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 1 1 7 - indicates blame-data start
573-
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 2 2
573+
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 2 2 - indicates another line of blame with the same data
574574
digits = parts[-1].split(" ")
575575
if len(digits) == 3:
576576
info = {'id': firstpart}
577577
blames.append([None, []])
578+
elif info['id'] != firstpart:
579+
info = {'id': firstpart}
580+
blames.append([commits.get(firstpart), []])
578581
# END blame data initialization
579582
else:
580583
m = self.re_author_committer_start.search(firstpart)
@@ -622,7 +625,7 @@ def blame(self, rev, file):
622625
text, = m.groups()
623626
blames[-1][0] = c
624627
blames[-1][1].append( text )
625-
info = None
628+
info = {'id': sha}
626629
# END if we collected commit info
627630
# END distinguish filename,summary,rest
628631
# END distinguish author|committer vs filename,summary,rest

0 commit comments

Comments
 (0)