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

Sign up
Appearance settings

Is there a way to do git blame --reverse? #1397

Answered by Byron
nasifimtiazohi asked this question in Q&A
Discussion options

I can do git blame on a file in the following way:

for commit, lines in repo.blame(commit, filepath):
 <process commit and lines>

However, I also want to do git blame --reverse START..END filename to blame the commit that deleted a line present at the START commit (or more specifically, the last commit within START..END where the line was present). Is there any way I can gitpython to achieve this?

You must be logged in to vote

I think with the current implementation it's not possible as it will always pass commit as argument. Ideally, one would be able to do something like repo.blame(filepath, reverse='<start>..<end>').
That would probably be fine for the parser, but it would need some refactoring to expose it in the public API.

Replies: 1 comment 2 replies

Comment options

I think with the current implementation it's not possible as it will always pass commit as argument. Ideally, one would be able to do something like repo.blame(filepath, reverse='<start>..<end>').
That would probably be fine for the parser, but it would need some refactoring to expose it in the public API.

You must be logged in to vote
2 replies
Comment options

repo.blame(('--reverse', 'HEAD~1..HEAD'), "myfile") does appear to work for my use cases. I'm unsure if I lucked out or that was intentional. (git-python==1.0.3).

Comment options

Thanks for sharing - if it works it works and I'd expect that it stays that way.

Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #1396 on January 11, 2022 01:45.

AltStyle によって変換されたページ (->オリジナル) /