So you want to know stats: who has done how many things in your git repo.
So you launch `git shortlog` since you know (or your team-mate knows), that it’s good for such things. Alas! More than one email address and perhaps even more than one nick are actually used by one person. And you have a problem. So if you don’t want to read manually then… read on.
You need to map. Mails with people. So, a `.mailmap`.
If `git log –pretty=”%an %ae” | sort -u` gives you:
riddle enigma firstname.lastname@example.org
Riddle Enigmã riddleThis@gmail.com
Riddle Enigma riddleThis@gmail.com
Dr Freeze email@example.com
Dr Freeze drFreeze@gmail.com
Then, using `git shortlog -sn` yields less-than-satisfactory result:
67 Riddle Enigmã
29 Dr Freeze
17 Riddle Enigma
Manual counting be damned, I want that map after all.
`vim .mailmap` # do this in top-level repo dir, where `.gitignore` or `.git` folder are located
## What’s inside?
We have few problems to solve. We want 3 lines (since we have 3 people). We don’t want to deal with Unicode. We want clarity, not obscurity.
- Each combo == one line
- Ideally we have: Nick <email>
- Organization is treated like <email>
- Unicode is avoided cause we know nothing about how it’s treated. Option a: one character (a and a tilde-like sign), option b: two characters (a AND the tilde-like sign).
Let’s hit it:
Ivy has three combos so far. Github one and two Gmail-ones. To be smart, we write:
Riddle has LOTS of combos. Insane (or is he?). Still, we get clever:
Riddle <riddleThis@gmail.com> # most gmail ones done
Riddle <TheVillains> # the org, to avoid riddleThis@gmail.com – email associated with it – as an author
Doc’s left now:
.mailmap looks like that:
Riddle <TheVillains> # org to avoid it’s mail as an author
We have what we wanted!
git shortlog -sn and