[PATCH 17/22] mailmap doc + tests: add better examples & test them

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change the mailmap documentation added in 0925ce4d49 (Add map_user()
and clear_mailmap() to mailmap, 2009-02-08) to continue discussing the
Jane/Joe example. I think this makes things a lot less confusing as
we're building up more complex examples using one set of data which
covers all the things we'd like to discuss.

Also add tests to assert that what our documentation says is what's
actually happening. This is mostly (or entirely) covered by existing
tests which I'm not deleting, but having these tests for the synopsis
makes it easier to follow-along while reading the tests & docs.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 Documentation/gitmailmap.txt | 49 ++++++++++++--------
 t/t4203-mailmap.sh           | 88 ++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+), 20 deletions(-)

diff --git a/Documentation/gitmailmap.txt b/Documentation/gitmailmap.txt
index 4e4677018b..55dfebd1b1 100644
--- a/Documentation/gitmailmap.txt
+++ b/Documentation/gitmailmap.txt
@@ -53,7 +53,7 @@ commit matching both the specified commit name and email address.
 EXAMPLES
 --------
 
-Example 1: Your history contains commits by two authors, Jane
+Your history contains commits by two authors, Jane
 and Joe, whose names appear in the repository under several forms:
 
 ------------
@@ -65,36 +65,45 @@ Jane D. <jane@desktop.(none)>
 ------------
 
 Now suppose that Joe wants his middle name initial used, and Jane
-prefers her family name fully spelled out. A proper `.mailmap` file
-would look like:
+prefers her family name fully spelled out. A `.mailmap` file to
+correct the names would look like:
 
 ------------
-Jane Doe         <jane@desktop.(none)>
 Joe R. Developer <joe@xxxxxxxxxxx>
+Jane Doe <jane@xxxxxxxxxxx>
+Jane Doe <jane@desktop.(none)>
 ------------
 
-Note how there is no need for an entry for `<jane@laptop.(none)>`, because the
-real name of that author is already correct.
+Note that there's no need to map the name for 'jane@laptop.(none)' to
+only correct the names. However, leaving the obviously broken
+`<jane@laptop.(none)>' and '<jane@desktop.(none)>' E-Mails as-is is
+usually not what you want. A `.mailmap` file which also corrects those
+is:
 
-Example 2: Your repository contains commits from the following
-authors:
+------------
+Joe R. Developer <joe@xxxxxxxxxxx>
+Jane Doe <jane@xxxxxxxxxxx> <jane@laptop.(none)>
+Jane Doe <jane@xxxxxxxxxxx> <jane@desktop.(none)>
+------------
+
+Finally, let's say that Joe and Jane shared an E-Mail address, but not
+a name, e.g. by having these two commits in the history generated by a
+bug reporting system. I.e. names appearing in history as:
 
 ------------
-nick1 <bugs@xxxxxxxxxx>
-nick2 <bugs@xxxxxxxxxx>
-nick2 <nick2@xxxxxxxxxx>
-santa <me@xxxxxxxxxx>
-claus <me@xxxxxxxxxx>
-CTO <cto@xxxxxxxxxxx>
+Joe <bugs@xxxxxxxxxxx>
+Jane <bugs@xxxxxxxxxxx>
 ------------
 
-Then you might want a `.mailmap` file that looks like:
+A full `.mailmap` file which also handles those cases (an addition of
+two lines to the above example) would be:
+
 ------------
-<cto@xxxxxxxxxx>                       <cto@xxxxxxxxxxx>
-Some Dude <some@xxxxxxx>         nick1 <bugs@xxxxxxxxxx>
-Other Author <other@xxxxxxxxx>   nick2 <bugs@xxxxxxxxxx>
-Other Author <other@xxxxxxxxx>         <nick2@xxxxxxxxxx>
-Santa Claus <santa.claus@xxxxxxxxxxxx> <me@xxxxxxxxxx>
+Joe R. Developer <joe@xxxxxxxxxxx>
+Jane Doe <jane@xxxxxxxxxxx> <jane@laptop.(none)>
+Jane Doe <jane@xxxxxxxxxxx> <jane@desktop.(none)>
+Joe R. Developer <joe@xxxxxxxxxxx> Joe <bugs@xxxxxxxxxxx>
+Jane Doe <jane@xxxxxxxxxxx> Jane <bugs@xxxxxxxxxxx>
 ------------
 
 
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 5d92880a5a..96ba5367c6 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -419,6 +419,94 @@ test_expect_success 'preserve canonical email case' '
 	test_cmp expect actual
 '
 
+test_expect_success 'gitmailmap(5) example output: setup' '
+	test_create_repo doc &&
+	test_commit -C doc --author "Joe Developer <joe@xxxxxxxxxxx>" A &&
+	test_commit -C doc --author "Joe R. Developer <joe@xxxxxxxxxxx>" B &&
+	test_commit -C doc --author "Jane Doe <jane@xxxxxxxxxxx>" C &&
+	test_commit -C doc --author "Jane Doe <jane@laptop.(none)>" D &&
+	test_commit -C doc --author "Jane D. <jane@desktop.(none)>" E
+'
+
+test_expect_success 'gitmailmap(5) example output: example #1' '
+	test_config -C doc mailmap.file ../doc.map &&
+	cat >doc.map <<-\EOF &&
+	Joe R. Developer <joe@xxxxxxxxxxx>
+	Jane Doe <jane@xxxxxxxxxxx>
+	Jane Doe <jane@desktop.(none)>
+	EOF
+
+	cat >expect <<-\EOF &&
+	Author Joe Developer <joe@xxxxxxxxxxx> maps to Joe R. Developer <joe@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Joe R. Developer <joe@xxxxxxxxxxx> maps to Joe R. Developer <joe@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Jane Doe <jane@xxxxxxxxxxx> maps to Jane Doe <jane@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Jane Doe <jane@laptop.(none)> maps to Jane Doe <jane@laptop.(none)>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Jane D <jane@desktop.(none)> maps to Jane Doe <jane@desktop.(none)>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+	EOF
+	git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'gitmailmap(5) example output: example #2' '
+	test_config -C doc mailmap.file ../doc.map &&
+	cat >doc.map <<-\EOF &&
+	Joe R. Developer <joe@xxxxxxxxxxx>
+	Jane Doe <jane@xxxxxxxxxxx> <jane@laptop.(none)>
+	Jane Doe <jane@xxxxxxxxxxx> <jane@desktop.(none)>
+	EOF
+
+	cat >expect <<-\EOF &&
+	Author Joe Developer <joe@xxxxxxxxxxx> maps to Joe R. Developer <joe@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Joe R. Developer <joe@xxxxxxxxxxx> maps to Joe R. Developer <joe@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Jane Doe <jane@xxxxxxxxxxx> maps to Jane Doe <jane@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Jane Doe <jane@laptop.(none)> maps to Jane Doe <jane@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Jane D <jane@desktop.(none)> maps to Jane Doe <jane@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+	EOF
+	git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'gitmailmap(5) example output: example #3' '
+	test_config -C doc mailmap.file ../doc.map &&
+	cat >>doc.map <<-\EOF &&
+	Joe R. Developer <joe@xxxxxxxxxxx> Joe <bugs@xxxxxxxxxxx>
+	Jane Doe <jane@xxxxxxxxxxx> Jane <bugs@xxxxxxxxxxx>
+	EOF
+
+	test_commit -C doc --author "Joe <bugs@xxxxxxxxxxx>" F &&
+	test_commit -C doc --author "Jane <bugs@xxxxxxxxxxx>" G &&
+
+	cat >>expect <<-\EOF &&
+
+	Author Joe <bugs@xxxxxxxxxxx> maps to Joe R. Developer <joe@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+
+	Author Jane <bugs@xxxxxxxxxxx> maps to Jane Doe <jane@xxxxxxxxxxx>
+	Committer C O Mitter <committer@xxxxxxxxxxx> maps to C O Mitter <committer@xxxxxxxxxxx>
+	EOF
+	git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
+	test_cmp expect actual
+'
+
+
 test_expect_success 'Shortlog output (complex mapping)' '
 	test_config mailmap.file complex.map &&
 	cat >complex.map <<-EOF &&
-- 
2.29.2.222.g5d2a92d10f8




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux