Two historical author names use the same imported mailbox. An address-only mailmap rule would collapse them together. If the names distinguish the two identities and you have verified that distinction, use a rule that matches both the old name and the old email. Then test an unmatched name on the same address to confirm you did not add an unintended catch-all.
Prerequisites and fixture
Use Git and Bash in a writable scratch directory. Save as mailmap.sh. The script creates a disposable non-bare repository, writes a local mailmap, and passes three fictional contacts to git check-mailmap --stdin. It ignores system and global Git configuration for the demo and does not create commits.
#!/usr/bin/env bash
set -eu
export GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_GLOBAL=/dev/null
d=$(mktemp -d ./mailmap-demo.XXXXXX)
trap 'rm -rf -- "$d"' EXIT
git init -q "$d"
cd -- "$d"
trap 'cd ..; rm -rf -- "$d"' EXIT
cat > .mailmap <<'MAP'
Morgan Vale <[email protected]> M. Vale <[email protected]>
Casey Reed <[email protected]> C. Reed <[email protected]>
MAP
actual=$(git check-mailmap --stdin <<'CONTACTS'
M. Vale <[email protected]>
C. Reed <[email protected]>
Other <[email protected]>
CONTACTS
)
expected='Morgan Vale <[email protected]>
Casey Reed <[email protected]>
Other <[email protected]>'
[[ "$actual" == "$expected" ]]
printf '%s\n' "$actual"
Run and read each line
bash mailmap.sh
Morgan Vale <[email protected]>
Casey Reed <[email protected]>
Other <[email protected]>
In each rule, the canonical contact appears first and the historical contact appears second. Both historical contacts carry the same address, but the two names match different entries. The third line stays unchanged. The comparison checks the whole ordered result, so accidentally mapping the third contact or exchanging the first two recipients would fail the example.
Troubleshoot a contributor report
If a real report resolves names differently, run the lookup inside the repository that feeds the report and check for mailmap.file or mailmap.blob configuration. Check whether the reporting command uses the mapped name and email fields rather than the raw commit fields. Testing the two ambiguous contacts plus a negative case gives more evidence than checking one contributor total, where mistakes can cancel each other out. A mailmap changes how a supporting command displays or groups identities. It does not rewrite the author fields stored in past commits. Keep raw contacts available to audits when that distinction matters.
git check-mailmap command reference · Git mailmap format · Java Samples Git tutorials