# git blame for a commit

6 messages from 2008-06-22 to 2008-06-23. Participants: Mircea Bardac, Ian Hilt, Jakub Narebski.
Thread: https://gitlist.dev/t/14093

## Mircea Bardac, 2008-06-22 22:32

Subject: git blame for a commit
Message-ID: <485ED2E5.3070906@mircea.bardac.net>
URL: https://gitlist.dev/e/485ED2E5.3070906%40mircea.bardac.net

```
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.

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

```

## Ian Hilt, 2008-06-23 03:40

Subject: Re: git blame for a commit
Message-ID: <alpine.LFD.1.10.0806222300410.23258@sys-0.hiltweb.site>
URL: https://gitlist.dev/e/alpine.LFD.1.10.0806222300410.23258%40sys-0.hiltweb.site
In-Reply-To: <485ED2E5.3070906@mircea.bardac.net>

```
On Sun, 22 Jun 2008 at 11:32pm +0100, Mircea Bardac wrote:

> 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.

> 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

```

## Mircea Bardac, 2008-06-23 09:04

Subject: Re: git blame for a commit
Message-ID: <485F6710.1080300@mircea.bardac.net>
URL: https://gitlist.dev/e/485F6710.1080300%40mircea.bardac.net
In-Reply-To: <alpine.LFD.1.10.0806222300410.23258@sys-0.hiltweb.site>

```
Ian Hilt wrote:
> On Sun, 22 Jun 2008 at 11:32pm +0100, Mircea Bardac wrote:
>> 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

```

## Jakub Narebski, 2008-06-23 10:01

Subject: Re: git blame for a commit
Message-ID: <m3ve00lbby.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3ve00lbby.fsf%40localhost.localdomain
In-Reply-To: <485F6710.1080300@mircea.bardac.net>

```
Mircea Bardac <dev@mircea.bardac.net> writes:
> Ian Hilt wrote:
>> On Sun, 22 Jun 2008 at 11:32pm +0100, Mircea Bardac wrote:
>>>
>>> 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"?

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).

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Ian Hilt, 2008-06-23 15:55

Subject: Re: git blame for a commit
Message-ID: <alpine.LFD.1.10.0806231149470.27742@sys-0.hiltweb.site>
URL: https://gitlist.dev/e/alpine.LFD.1.10.0806231149470.27742%40sys-0.hiltweb.site
In-Reply-To: <m3ve00lbby.fsf@localhost.localdomain>

```
On Mon, 23 Jun 2008 at 3:01am -0700, Jakub Narebski wrote:

> 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

```

## Jakub Narebski, 2008-06-23 16:29

Subject: Re: git blame for a commit
Message-ID: <200806231829.22004.jnareb@gmail.com>
URL: https://gitlist.dev/e/200806231829.22004.jnareb%40gmail.com
In-Reply-To: <alpine.LFD.1.10.0806231149470.27742@sys-0.hiltweb.site>

```
On Mon, 23 Jun 2008, Ian Hilt wrote:
> On Mon, 23 Jun 2008 at 3:01am -0700, Jakub Narebski wrote:
> 
> > 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...
-- 
Jakub Narebski
Poland

```
