Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6e86f8a

Browse filesBrowse 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. Added real test to verify blame works against the actual commit, not only a mock of what was produced by blame in old git releases
1 parent a848569 commit 6e86f8a
Copy full SHA for 6e86f8a

2 files changed

+14-2Lines changed: 14 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/db/cmd/base.py‎

Copy file name to clipboardExpand all lines: git/db/cmd/base.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,9 @@ def blame(self, rev, file):
701701
if len(digits) == 3:
702702
info = {'id': firstpart}
703703
blames.append([None, []])
704+
elif info['id'] != firstpart:
705+
info = {'id': firstpart}
706+
blames.append([commits.get(firstpart), []])
704707
# END blame data initialization
705708
else:
706709
m = self.re_author_committer_start.search(firstpart)
@@ -747,8 +750,8 @@ def blame(self, rev, file):
747750
m = self.re_tab_full_line.search(line)
748751
text, = m.groups()
749752
blames[-1][0] = c
750-
blames[-1][1].append( text )
751-
info = None
753+
blames[-1][1].append(text)
754+
info = { 'id' : sha }
752755
# END if we collected commit info
753756
# END distinguish filename,summary,rest
754757
# END distinguish author|committer vs filename,summary,rest
Collapse file

‎git/test/db/base.py‎

Copy file name to clipboardExpand all lines: git/test/db/base.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ def test_should_display_blame_information(self, git):
283283
assert_true( isinstance( tlist[0], basestring ) )
284284
assert_true( len( tlist ) < sum( len(t) for t in tlist ) ) # test for single-char bug
285285

286+
def test_blame_real(self):
287+
c = 0
288+
for item in self.rorepo.head.commit.tree.traverse(
289+
predicate=lambda i, d: i.type == 'blob' and i.path.endswith('.py')):
290+
c += 1
291+
b = self.rorepo.blame(self.rorepo.head, item.path)
292+
#END for each item to traverse
293+
assert c
294+
286295
def test_untracked_files(self):
287296
base = self.rorepo.working_tree_dir
288297
files = ( join_path_native(base, "__test_myfile"),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.