Skip to contentSkip to conversation

git blame for a commit

DISCUSSION Mircea Bardac 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi everyone,

Is there any straightforward way of doing git blame for all the files that got changed in a commit. Problems are renames, deletes and copies.

I was also thinking of git diff with a huge number of context lines, but this one feels a bit hacking. "git diff" is also missing author info, so "git blame" is a bit more desirable.

Has anyone ever done this before?

Many thanks.

Signature · 2 lines
Mircea
http://mircea.bardac.net
#1 lore raw
Quoted 4 lines · Mircea Bardac

Hi everyone,

Is there any straightforward way of doing git blame for all the files that got changed in a commit. Problems are renames, deletes and copies.

Sounds like you want to track files rather than content. Git tracks the latter.

Quoted 7 lines

I was also thinking of git diff with a huge number of context lines, but this one feels a bit hacking. "git diff" is also missing author info, so "git blame" is a bit more desirable.

Has anyone ever done this before?

Many thanks.

Try "git diff --name-only commit1..commit2" or "git log --name-only commit1..commit2". This will give you only the names of the files in which content was altered. Other than that, I think you should re-read (hint) git-blame(1). It's focus is on content, not files as a whole.

--
Ian Hilt
Ian.Hilt (at) gmx.com
GnuPG key: 0x4AFC1EE3

#2 lore raw
Quoted 6 lines · Ian Hilt
Quoted 2 lines · Mircea Bardac

Is there any straightforward way of doing git blame for all the files that got changed in a commit. Problems are renames, deletes and copies.

Sounds like you want to track files rather than content. Git tracks the latter.

Hmm... I'm not really sure that my initial intention was to track files. I've given this some more thought and I realized that what I actually want is a "git diff" with blame info included. I want this information in order to facilitate code reviewing.

It is true that this would be a front-end functionality, but I am not sure at the moment what the best approach would be for something like this. I would see this something like

$ git diff --blame[="parameters_for_blame"] commit1..commit2
but this is just a thought.

Has anyone tried blaming a "git diff"?

Many thanks.

--
Mircea
http://mircea.bardac.net

#3 lore raw
Quoted 16 lines · Mircea Bardac
Quoted 9 lines · Ian Hilt
Quoted 4 lines · Mircea Bardac

Is there any straightforward way of doing git blame for all the files that got changed in a commit. Problems are renames, deletes and copies.

Sounds like you want to track files rather than content. Git tracks the
latter.

Hmm... I'm not really sure that my initial intention was to track files. I've given this some more thought and I realized that what I actually want is a "git diff" with blame info included. I want this information in order to facilitate code reviewing.

Quoted 7 lines

It is true that this would be a front-end functionality, but I am not sure at the moment what the best approach would be for something like this. I would see this something like

$ git diff --blame[="parameters_for_blame"] commit1..commit2
but this is just a thought.

Has anyone tried blaming a "git diff"?

I think you could script it using "git diff", and "git blame -L m,n", where line ranges would be calculated from git diff header for post-image, or both pre-image and post-image (in the case of deletions).

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#4 lore raw
Quoted 3 lines · Jakub Narebski

I think you could script it using "git diff", and "git blame -L m,n", where line ranges would be calculated from git diff header for post-image, or both pre-image and post-image (in the case of deletions).

Maybe I'm missing something, but I thought git-blame only worked with the files in the Git working directory. Therefore, if a file had been deleted it would not be reachable with git-blame, whether you diff'ed the pre- and post-image or not.

--
Ian Hilt
Ian.Hilt (at) gmx.com
GnuPG key: 0x4AFC1EE3

#5 lore raw
Quoted 10 lines · Ian Hilt
Quoted 3 lines · Jakub Narebski

I think you could script it using "git diff", and "git blame -L m,n", where line ranges would be calculated from git diff header for post-image, or both pre-image and post-image (in the case of deletions).

Maybe I'm missing something, but I thought git-blame only worked with the files in the Git working directory. Therefore, if a file had been deleted it would not be reachable with git-blame, whether you diff'ed the pre- and post-image or not.

You can give blame the revision to start blaming from; that's what I meant the "pre-image" blame (staring from parent revision).

I'm not that sure if it is the best solution...

Signature · 2 lines
Jakub Narebski
Poland