Skip to content

Repo.blame don't return multi lines. #47

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

Closed
niyaton opened this issue Feb 15, 2012 · 6 comments
Closed

Repo.blame don't return multi lines. #47

niyaton opened this issue Feb 15, 2012 · 6 comments
Assignees

Comments

@niyaton
Copy link
Contributor

niyaton commented Feb 15, 2012

According to API reference,


The blame information for the given file at the given revision.

Parm rev: revision specifier, see git-rev-parse for viable options.
Returns: list: [git.Commit, list: []] A list of tuples associating a Commit object with a list of lines that changed within the given commit. The Commit objects will be given in order of appearance.


blame method returns list of lines but I think the method always returns only one line.
The method pick up the first line of lines which were written in same commit (other lines are skipped and method don't return its information).

The behavior come from the lien 620 of git/repo/base.py.
The variable 'info' is initialized only when a line is first line of same commit.
But 'info' will be None after processing a line (the lien is not commit information).

We have to initialize 'info' to process subsequent lines.

@mitar
Copy link

mitar commented Jun 6, 2012

I can confirm this problem with Python-0.3.2.RC1.tar.gz from PyPi, but it seems it works correctly with current master branch (tested with cd72d78).

@Byron
Copy link
Member

Byron commented Jun 7, 2012

Hi niyaton,

Can you confirm that it works for you with the latest version on the 0.3 branch ?

Thanks

@estebank
Copy link

I believe this is still present in 0.3.2 RC1.

When blaming a file I only get one line of code per blame element. It's particularly annoying in the case of empty lines.

 (...)
 [<git.Commit "d7c7a1a1bdb22db4c4a4277564cf62dc89b4d42f">, ['']],
 [<git.Commit "15f829a5587d31a33b4be1a93ae277726c6ba1ae">, ['    if m:']],
 [<git.Commit "d7c7a1a1bdb22db4c4a4277564cf62dc89b4d42f">, ['']],
 (...)

vitalif added a commit to vitalif/GitPython that referenced this issue Nov 28, 2013
@vitalif
Copy link

vitalif commented Nov 28, 2013

It's very easy to fix, see the commit from my fork (link is in the issue because my commit references it)

@Byron
Copy link
Member

Byron commented Nov 19, 2014

I could verify that the fix by @vitalif doesn't break a test, but on the other hand, the blame test is not particularly strict either. Also it seems the fix tries to reference a variable which is possibly undefined.
Therefore I shall have a look in 0.3.5 .

@Byron Byron added this to the v0.3.5 - bugfixes milestone Nov 19, 2014
@Byron Byron self-assigned this Jan 8, 2015
@Byron
Copy link
Member

Byron commented Jan 8, 2015

The latest version definitely supports multiple lines per blame object.
Additionally, I have added a unit-test to verify this truly works.

@Byron Byron closed this as completed Jan 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants