git-check-mailmap
Verify mailmap file validity and consistency
TLDR
Look up the canonical name associated with an email address
SYNOPSIS
git check-mailmap [--[no-]strict] [--raw] [--] < <in-file>
git check-mailmap [--[no-]strict] [--raw] [--] <name> <email>
PARAMETERS
--strict
If an entry is not found in the mailmap, the command will exit with an error status (1). Without this option, if an identity is not found, the original identity is outputted as is.
--no-strict
Explicitly specifies the default non-strict behavior: if an entry is not found in the mailmap, the original identity is outputted without error.
--raw
If an entry is found in the mailmap, the canonicalized identity is outputted. If no entry is found, the original input identity (name and email) is outputted verbatim without any modification.
--
Separates command-line options from the arguments that follow. Useful when names or emails might otherwise be mistaken for options.
<name>
The name part of the identity to check, used when providing identity directly as arguments.
<email>
The email part of the identity to check, used when providing identity directly as arguments. Can be empty if only a name is provided.
< <in-file>
Reads identities from standard input, where each line should contain an identity in the format "Name <email>".
DESCRIPTION
The git check-mailmap command is a plumbing command used to canonicalize author and committer identities based on the Git .mailmap mechanism. It reads identity lines (typically "Name <email>") from standard input or provided as arguments and outputs their canonicalized form to standard output. This is particularly useful when different identities (names and emails) have been used for the same person across a project's history, allowing tools like git shortlog or git log to present a unified view. The command consults .mailmap files located in the current repository's top-level directory, as well as paths specified by the mailmap.file and mailmap.blob configuration variables.
CAVEATS
This command relies on the presence and correct configuration of a .mailmap file. If no mailmap is found or configured, it essentially acts as an identity function unless --strict is used. It's primarily a low-level helper for other Git commands, not typically invoked directly by end-users.
MAILMAP FILE FORMAT
The .mailmap file contains lines that map old identities to new, canonical ones. Each line can have one of two formats:
Canonical Name <canonical@email> <old@email>
or
Canonical Name <canonical@email> Old Name <old@email>
The first format maps an old email to a new name and email. The second format maps an old name and email to a new name and email. Lines starting with # are comments.
CONFIGURATION
Git can be configured to look for mailmap files beyond the top-level .mailmap file. The mailmap.file configuration variable can specify a path to an additional mailmap file. The mailmap.blob variable can point to a blob object ID within the repository that contains mailmap entries, allowing for project-wide mailmap definitions to be committed and versioned.
HISTORY
The .mailmap feature, which git-check-mailmap supports, has been a part of Git since its early days (around 2007) to address the common issue of multiple identities for the same individual in a project's history. git-check-mailmap itself was introduced as a plumbing command to provide a programmatic interface for this canonicalization, allowing other tools to leverage the mailmap logic without reimplementing it.
SEE ALSO
git-shortlog(1), git-log(1), git-config(1)