threads / discuss / 45475

blame --line-porcelain is providing me with funny output

Subject: blame --line-porcelain is providing me with funny output

## tl;dr

3 messages between Mar 23, 2017 and Mar 23, 2017.

replies: 2people: 3as markdown or json

Edmundo Carmona Antoranz· Mar 23, 2017, 00:32 UTC · lore
Hi, everybody!

As part of my improvements to difflame I want to use revision information as provided by blame --line-porcelain so that I can avoid some git calls to cat-file -p to get revision information hoping that information would be a match. However I'm not finding that to be the case.

$ git blame --no-progress -w --line-porcelain -L 72,72 4e59582ff70d299f5a88449891e78d15b4b3fabe -- t/lib-submodule-update.sh

3290fe6dd2a7e2bb35ac760443335dec58802ff1 72 72 1
author Stefan Beller
author-mail <somemail@gmail.com>
author-time 1484160452
author-tz -0800
committer Junio C Hamano
committer-mail <somemail@pobox.com>
committer-time 1484337771
committer-tz -0800
summary lib-submodule-update.sh: reduce use of subshell by using "git -C"
previous d7dffce1cebde29a0c4b309a79e4345450bf352a t/lib-submodule-update.sh
filename t/lib-submodule-update.sh
                       git -C sub1 checkout modifications &&

If we then take a look at the information on that revision using cat-file -p on the revision:

$ git cat-file -p 3290fe6dd2a7e2bb35ac760443335dec58802ff1

tree 7df89dad28ec8b08875395265a3f2e13ba180174 parent d7dffce1cebde29a0c4b309a79e4345450bf352a author Stefan Beller <somemail@google.com> 1484160452 -0800 committer Junio C Hamano <somemail@pobox.com> 1484337771 -0800

(which, just in case, resembles the information provided by git show... but is simpler to parse with cat-file).

Committer mails are matching, however author mail does not match between line-porcelain and cat-file. Is there a reason for that?

Thanks in advance.
Dennis Kaarsemaker· Mar 23, 2017, 11:03 UTC · re: Edmundo Carmona Antoranz · lore

Re: blame --line-porcelain is providing me with funny output

On Wed, 2017-03-22 at 18:32 -0600, Edmundo Carmona Antoranz wrote:
Show 9 quoted lines
> 
> $ git blame --no-progress -w --line-porcelain -L 72,72
> author-mail <somemail@gmail.com>
> 
> $ git cat-file -p 3290fe6dd2a7e2bb35ac760443335dec58802ff1
> author Stefan Beller <somemail@google.com> 1484160452 -0800
> 
> Committer mails are matching, however author mail does not match
> between line-porcelain and cat-file. Is there a reason for that?

The commit object has Stefan's Google address, but git.git's mailmap maps that to his gmail address.

git blame actually does this mapping, where git cat-file does not.
-- 
Dennis Kaarsemaker
http://www.kaarsemaker.net
Stefan Beller· Mar 23, 2017, 18:01 UTC · re: Dennis Kaarsemaker · lore

Re: blame --line-porcelain is providing me with funny output

On Thu, Mar 23, 2017 at 4:03 AM, Dennis Kaarsemaker <dennis@kaarsemaker.net> wrote:

Show 15 quoted lines
> On Wed, 2017-03-22 at 18:32 -0600, Edmundo Carmona Antoranz wrote:
>>
>> $ git blame --no-progress -w --line-porcelain -L 72,72
>> author-mail <somemail@gmail.com>
>>
>> $ git cat-file -p 3290fe6dd2a7e2bb35ac760443335dec58802ff1
>> author Stefan Beller <somemail@google.com> 1484160452 -0800
>>
>> Committer mails are matching, however author mail does not match
>> between line-porcelain and cat-file. Is there a reason for that?
>
> The commit object has Stefan's Google address, but git.git's  mailmap
> maps that to his gmail address.
>
> git blame actually does this mapping, where git cat-file does not.
Yes, I think the plumbing tools in general want to ignore the .mailmap file.

The committer (Junio) does use the email address, which is recorded as his primary address in .mailmap as well, so no matter if the .mailmap file is taken into account, it is the same email address.

Currently I contribute patches via the @google address, but the @gmail address is marked as the primary address in the .mailmap file, such that it depends whether the .mailmap file is taken into account which email address is displayed.

So doesn't depend on the author or committer fields, but instead it depends on the underlying data (.mailmap and recorded person for author/committer).

For the exact mechanism of .mailmap look at "man git shortlog" that has a section MAPPING AUTHORS), which states its effect, but not the purpose of mapping persons:

    The .mailmap feature is used to coalesce together commits
    by the same person in the shortlog, where their name and/or
    email address was spelled differently.

One purpose could be to just fix data (i.e. misspelled name, unconfigured repo; back then there were quite a few name="" email="root@localhost" commits).

Another aspect is to keep track of the same person at different stages of life, e.g. when switching employers (or just email providers), you may contribute from different email addresses and want to appear as the same person in porcelain-viewed commits. There are quite a few examples in the .mailmap file for different email addresses.

One notable example is found in 94b410bba8 (.mailmap: Map email addresses to names, 2013-07-12):

    While the most changes happen at the email addresses, we also have a
    name change in here. Karl Hasselström is now known as Karl Wiberg
    due to marriage. Congratulations!

Thanks, Stefan

← back to recent threads