Search code examples
git

Using git check-mailmap correctly


Context

There is a .mailmap file at the root of the project in question. It consists of entries such as these:

Some User <[email protected]> <[email protected]>
Some User <[email protected]> <[email protected]>
Another User <[email protected]> <[email protected]>
...

I found documentation on retrieving canonical contact data for any given user using git check-mailmap:

https://git-scm.com/docs/git-check-mailmap

Question

Simple question, to which I did not find a concise answer - how does one use the command correctly?

Documentation provides syntax as follows:

git check-mailmap [<options>] <contact>

However entering e.g. any the following

git check-mailmap [email protected]
git check-mailmap Some User
git check-mailmap --std

yields no result other than

fatal: unable to parse contact ...

In addition I entered git check-mailmap --help to look for additional info, but it seems to me like the provided HTML is equivalent to the page I linked earlier.

So how is git check-mailmap being used properly?


Solution

  • An anwer was found thanks to @phd. See comment section under opening post for details given.

    The syntax I was using to call git check-mailmap is incorrect:

    git check-mailmap [email protected]
    git check-mailmap Some User
    git check-mailmap --std
    

    Instead, in order to retrieve a canonical alias, both a username and a corresponding address need to be provided.

    In the example given a valid call may look like this:

    git check-mailmap 'Some User <[email protected]>'
    

    and should yield:

    Some User <[email protected]>
    

    A handy way to check .mailmap validity is usage of git shortlog -se.