Skip to content

Commit 8e3883a

Browse files
committed
Merge branch 'blamefix' into 0.3
2 parents d6d544f + 55885e0 commit 8e3883a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

git/repo/base.py

+5-2
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

git/test/test_repo.py

+9
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@ def test_should_display_blame_information(self, git):
269269
assert_true( isinstance( tlist[0], basestring ) )
270270
assert_true( len( tlist ) < sum( len(t) for t in tlist ) ) # test for single-char bug
271271

272+
def test_blame_real(self):
273+
c = 0
274+
for item in self.rorepo.head.commit.tree.traverse(
275+
predicate=lambda i, d: i.type == 'blob' and i.path.endswith('.py')):
276+
c += 1
277+
b = self.rorepo.blame(self.rorepo.head, item.path)
278+
#END for each item to traverse
279+
assert b
280+
272281
def test_untracked_files(self):
273282
base = self.rorepo.working_tree_dir
274283
files = ( join_path_native(base, "__test_myfile"),

0 commit comments

Comments
 (0)