From: Junio C Hamano <hidden> Date: 2016-08-11 19:29:56
The code had "/pub/scm/linux/kernel/git/" hardcoded which was
too specific to the kernel project.
With this, a line in the .mailmap file:
# repo-abbrev: /pub/scm/linux/kernel/git/
can be used to cause the substring to be abbreviated to /.../
on the title line of the commit message.
Signed-off-by: Junio C Hamano <redacted>
---
builtin-shortlog.c | 24 ++++++++++++++++++++++--
contrib/mailmap.linux | 2 ++
2 files changed, 24 insertions(+), 2 deletions(-)
@@ -3,6 +3,8 @@ # So have an email->real name table to translate the # (hopefully few) missing names #+# repo-abbrev: /pub/scm/linux/kernel/git/+# Adrian Bunk <bunk@stusta.de> Andreas Herrmann <aherrman@de.ibm.com> Andrew Morton <akpm@osdl.org>
Remove support for the magical "repo-abbrev" comment in .mailmap
files. This was added to .mailmap parsing in [1], as a generalized
feature of the git-shortlog Perl script added earlier in [2].
There was no documentation or tests for this feature, and I don't
think it's used in practice anymore.
What it did was to allow you to specify a single string to be
search-replaced with "/.../" in the .mailmap file. E.g. for
linux.git's current .mailmap:
git archive --remote=git@gitlab.com:linux-kernel/linux.git \
HEAD -- .mailmap | grep -a repo-abbrev
# repo-abbrev: /pub/scm/linux/kernel/git/
Then when running e.g.:
git shortlog --merges --author=Linus -1 v5.10-rc7..v5.10 | grep Merge
We'd emit (the [...] is mine):
Merge tag [...]git://git.kernel.org/.../tip/tip
But will now emit:
Merge tag [...]git.kernel.org/pub/scm/linux/kernel/git/tip/tip
I think at this point this is just a historical artifact we can get
rid of. It was initially meant for Linus's own use when we integrated
the Perl script[2], but since then it seems he's stopped using it.
Digging through Linus's release announcements on the LKML[3] the last
release I can find that made use of this output is Linux 2.6.25-rc6
back in March 2008[4]. Later on Linus started using --no-merges[5],
and nowadays seems to prefer some custom not-quite-shortlog format of
merges from lieutenants[6].
You will still see it on linux.git if you run "git shortlog" manually
yourself with --merges, with this removed you can still get the same
output with:
git log --pretty=fuller v5.10-rc7..v5.10 |
sed 's!/pub/scm/linux/kernel/git/!/.../!g' |
git shortlog
Arguably we should do the same for the search-replacing of "[PATCH]"
at the beginning with "". That seems to be another relic of a bygone
era when linux.git patches would have their E-Mail subject lines
applied as-is by "git am" or whatever. But we documented that feature
in "git-shortlog(1)", and it seems more widely applicable than
something purely kernel-specific.
1. 7595e2ee6ef (git-shortlog: make common repository prefix
configurable with .mailmap, 2006-11-25)
2. fa375c7f1b6 (Add git-shortlog perl script, 2005-06-04)
3. https://lore.kernel.org/lkml/
4. https://lore.kernel.org/lkml/alpine.LFD.1.00.0803161651350.3020@woody.linux-foundation.org/
5. https://lore.kernel.org/lkml/BANLkTinrbh7Xi27an3uY7pDWrNKhJRYmEA@mail.gmail.com/
6. https://lore.kernel.org/lkml/CAHk-=wg1+kf1AVzXA-RQX0zjM6t9J2Kay9xyuNqcFHWV-y5ZYw@mail.gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
I wondered what this repo-abbrev thing was while reading thorugh
recent mailmap.c traffic. I was a bit on the fence about this being a
RFC/PATCH, but I guess if people hate this & want to keep it that's
fine, but if not this should be ready for inclusion.
Surely has some conflicts with brian's recent submission, but I wanted
to get it out of my queue sooner than later.
builtin/blame.c | 2 +-
builtin/check-mailmap.c | 2 +-
builtin/commit.c | 2 +-
builtin/log.c | 2 +-
builtin/shortlog.c | 16 ++------------
mailmap.c | 47 ++++++++++-------------------------------
mailmap.h | 2 +-
pretty.c | 2 +-
shortlog.h | 1 -
9 files changed, 19 insertions(+), 57 deletions(-)
@@ -231,13 +206,13 @@ static int read_mailmap_blob(struct string_list *map,if(type!=OBJ_BLOB)returnerror("mailmap is not a blob: %s",name);-read_mailmap_string(map,buf,repo_abbrev);+read_mailmap_string(map,buf);free(buf);return0;}-intread_mailmap(structstring_list*map,char**repo_abbrev)+intread_mailmap(structstring_list*map){interr=0;
@@ -247,10 +222,10 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)if(!git_mailmap_blob&&is_bare_repository())git_mailmap_blob="HEAD:.mailmap";-err|=read_mailmap_file(map,".mailmap",repo_abbrev);+err|=read_mailmap_file(map,".mailmap");if(startup_info->have_repository)-err|=read_mailmap_blob(map,git_mailmap_blob,repo_abbrev);-err|=read_mailmap_file(map,git_mailmap_file,repo_abbrev);+err|=read_mailmap_blob(map,git_mailmap_blob);+err|=read_mailmap_file(map,git_mailmap_file);returnerr;}
On Tue, Jan 5, 2021 at 5:04 AM Ævar Arnfjörð Bjarmason [off-list ref] wrote:
Remove support for the magical "repo-abbrev" comment in .mailmap
files. This was added to .mailmap parsing in [1], as a generalized
feature of the git-shortlog Perl script added earlier in [2].
Ack. As you found out, I haven't used this in ages.
Linus
... which passes before this, makes the test fail after this patch. It
seems our test coverage for comments is basically zero here. It might
make sense to first introduce some testing around comments (maybe not in
this "complex mapping" test, though) before doing this patch you're
posting here, but keeping something like
if (buffer[0] == '#')
return;
Martin
From: Junio C Hamano <hidden> Date: 2021-01-05 23:07:45
Ævar Arnfjörð Bjarmason [off-list ref] writes:
Remove support for the magical "repo-abbrev" comment in .mailmap
files. This was added to .mailmap parsing in [1], as a generalized
feature of the git-shortlog Perl script added earlier in [2].
...
I wondered what this repo-abbrev thing was while reading thorugh
recent mailmap.c traffic. I was a bit on the fence about this being a
RFC/PATCH, but I guess if people hate this & want to keep it that's
fine, but if not this should be ready for inclusion.
Surely has some conflicts with brian's recent submission, but I wanted
to get it out of my queue sooner than later.
I'd expect that nobody would say anything until this change hits a
released version, and then after another release or two when it hits a
binary-packaged distro release, we may hear a regression report.
Or perhaps not.
In other words, we won't see a complaint (other than any obvious ones
we'd notice during review, like "shouldn't we be skipping comments?")
by cooking this in 'next', so I'd prefer to fast-track a topic like this
quickly to 'master' but make sure we can revert it anytime. Which in
turn means that it would be nice to see it while the codepaths involved
is expected to be quiet for a while. So, let's ignore this topic while
the other mailmap topic is in flight and then revisit it after it
graduates to 'master'.
Thanks.
Add tests for mailmap's handling of "<>", which is allowed on the RHS,
but not the LHS of a "<LHS> <RHS>" pair.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
Add tests for mailmap's handling of whitespace, i.e. how it trims
space within "<>" and around author names.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
@@ -786,4 +786,56 @@ test_expect_success 'comment syntax: setup' 'test_cmpexpectactual'+test_expect_success'whitespace syntax: setup''+test_create_repospace&&+test_commit-Cspace--author"A <a@example.com>"A&&+test_commit-Cspace--author"B <b@example.com>"B&&+test_commit-Cspace--author" C <c@example.com>"C&&+test_commit-Cspace--author" D <d@example.com>"D&&+test_commit-Cspace--author"E E <e@example.com>"E&&+test_commit-Cspace--author"F F <f@example.com>"F&&+test_commit-Cspace--author"G G <g@example.com>"G&&+test_commit-Cspace--author"H H <h@example.com>"H&&++test_config-Cspacemailmap.file../space.map&&+cat>>space.map<<-\EOF&&+Ah<ah@example.com><a@example.com>+Bee<bee@example.com><b@example.com>+Cee<cee@example.com>C<c@example.com>+dee<dee@example.com>D<d@example.com>+eee<eee@example.com>EE<e@example.com>+eff<eff@example.com>FF<f@example.com>+gee<gee@example.com>GG<g@example.com>+aitch<aitch@example.com>HH<h@example.com>+EOF++cat>expect<<-\EOF&&+AuthorA<a@example.com>mapstoA<a@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorB<b@example.com>mapstoB<b@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorC<c@example.com>mapstoCee<cee@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorD<d@example.com>mapstodee<dee@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorEE<e@example.com>mapstoeee<eee@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorFF<f@example.com>mapstoeff<eff@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorGG<g@example.com>mapstogee<gee@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorHH<h@example.com>mapstoHH<h@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>+EOF+git-Cspacelog--reverse--pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n">actual&&+test_cmpexpectactual+'+ test_done
Add documentation and more tests for case-insensitivity. The existing
test only matched on the E-Mail part, but as shown here we also match
the name with strcasecmp().
This behavior was last discussed on the mailing list in the thread
starting at [1]. It seems we're keeping it like this, so let's
document it.
1. https://lore.kernel.org/git/87czykvg19.fsf@evledraar.gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
Documentation/gitmailmap.txt | 5 +++++
t/t4203-mailmap.sh | 14 ++++++++++++++
2 files changed, 19 insertions(+)
@@ -49,6 +49,11 @@ commit matching the specified commit email address, and: which allows mailmap to replace both the name and the email of a commit matching both the specified commit name and email address.+Both E-Mails and names are matched case-insensitively. For example+this would also match the 'Commit Name <commit@email.xx>' above:+--+Proper Name <proper@email.xx> CoMmIt NaMe <CoMmIt@EmAiL.xX>+-- EXAMPLES --------
Remove support for the magical "repo-abbrev" comment in .mailmap
files. This was added to .mailmap parsing in [1], as a generalized
feature of the git-shortlog Perl script added earlier in [2].
There was no documentation or tests for this feature, and I don't
think it's used in practice anymore.
What it did was to allow you to specify a single string to be
search-replaced with "/.../" in the .mailmap file. E.g. for
linux.git's current .mailmap:
git archive --remote=git@gitlab.com:linux-kernel/linux.git \
HEAD -- .mailmap | grep -a repo-abbrev
# repo-abbrev: /pub/scm/linux/kernel/git/
Then when running e.g.:
git shortlog --merges --author=Linus -1 v5.10-rc7..v5.10 | grep Merge
We'd emit (the [...] is mine):
Merge tag [...]git://git.kernel.org/.../tip/tip
But will now emit:
Merge tag [...]git.kernel.org/pub/scm/linux/kernel/git/tip/tip
I think at this point this is just a historical artifact we can get
rid of. It was initially meant for Linus's own use when we integrated
the Perl script[2], but since then it seems he's stopped using it.
Digging through Linus's release announcements on the LKML[3] the last
release I can find that made use of this output is Linux 2.6.25-rc6
back in March 2008[4]. Later on Linus started using --no-merges[5],
and nowadays seems to prefer some custom not-quite-shortlog format of
merges from lieutenants[6].
You will still see it on linux.git if you run "git shortlog" manually
yourself with --merges, with this removed you can still get the same
output with:
git log --pretty=fuller v5.10-rc7..v5.10 |
sed 's!/pub/scm/linux/kernel/git/!/.../!g' |
git shortlog
Arguably we should do the same for the search-replacing of "[PATCH]"
at the beginning with "". That seems to be another relic of a bygone
era when linux.git patches would have their E-Mail subject lines
applied as-is by "git am" or whatever. But we documented that feature
in "git-shortlog(1)", and it seems more widely applicable than
something purely kernel-specific.
1. 7595e2ee6ef (git-shortlog: make common repository prefix
configurable with .mailmap, 2006-11-25)
2. fa375c7f1b6 (Add git-shortlog perl script, 2005-06-04)
3. https://lore.kernel.org/lkml/
4. https://lore.kernel.org/lkml/alpine.LFD.1.00.0803161651350.3020@woody.linux-foundation.org/
5. https://lore.kernel.org/lkml/BANLkTinrbh7Xi27an3uY7pDWrNKhJRYmEA@mail.gmail.com/
6. https://lore.kernel.org/lkml/CAHk-=wg1+kf1AVzXA-RQX0zjM6t9J2Kay9xyuNqcFHWV-y5ZYw@mail.gmail.com/
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
builtin/blame.c | 2 +-
builtin/check-mailmap.c | 2 +-
builtin/commit.c | 2 +-
builtin/log.c | 2 +-
builtin/shortlog.c | 16 ++------------
mailmap.c | 48 +++++++++++------------------------------
mailmap.h | 2 +-
pretty.c | 2 +-
shortlog.h | 1 -
9 files changed, 21 insertions(+), 56 deletions(-)
@@ -231,13 +209,13 @@ static int read_mailmap_blob(struct string_list *map,if(type!=OBJ_BLOB)returnerror("mailmap is not a blob: %s",name);-read_mailmap_string(map,buf,repo_abbrev);+read_mailmap_string(map,buf);free(buf);return0;}-intread_mailmap(structstring_list*map,char**repo_abbrev)+intread_mailmap(structstring_list*map){interr=0;
@@ -247,10 +225,10 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)if(!git_mailmap_blob&&is_bare_repository())git_mailmap_blob="HEAD:.mailmap";-err|=read_mailmap_file(map,".mailmap",repo_abbrev);+err|=read_mailmap_file(map,".mailmap");if(startup_info->have_repository)-err|=read_mailmap_blob(map,git_mailmap_blob,repo_abbrev);-err|=read_mailmap_file(map,git_mailmap_file,repo_abbrev);+err|=read_mailmap_blob(map,git_mailmap_blob);+err|=read_mailmap_file(map,git_mailmap_file);returnerr;}
Refactor a few more tests to use the new "--append" option to
"test_commit". I added it for use in the mailmap tests, but this
demonstrates how useful it is in general.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t1412-reflog-loop.sh | 7 ++-----
t/t2012-checkout-last.sh | 12 +++---------
t/t7810-grep.sh | 18 +++---------------
3 files changed, 8 insertions(+), 29 deletions(-)
@@ -5,13 +5,9 @@ test_description='checkout can switch to last branch and merge base' ../test-lib.sh test_expect_success'setup''-echohello>world&&-gitaddworld&&-gitcommit-minitial&&+test_commitinitialworldhello&&gitbranchother&&-echo"hello again">>world&&-gitaddworld&&-gitcommit-msecond+test_commit--appendsecondworld"hello again"' test_expect_success'"checkout -" does not work initially''
@@ -93,9 +89,7 @@ test_expect_success 'switch to twelfth from the last' ' test_expect_success'merge base test setup''gitcheckout-banotherother&&-echo"hello again">>world&&-gitaddworld&&-gitcommit-mthird+test_commit--appendthirdworld"hello again"' test_expect_success'another...master''
Add an --append option to test_commit to append <contents> to the
<file> we're writing to. This simplifies a lot of test setup, as shown
in some of the tests being changed here.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 39 +++++++--------------------------------
t/test-lib-functions.sh | 14 +++++++++++++-
2 files changed, 20 insertions(+), 33 deletions(-)
@@ -183,6 +183,9 @@ debug () {# Run all git commands in directory <dir># --notick# Do not call test_tick before making a commit+# --append+# Use "echo >>" instead of "echo >" when writing "<contents>" to+# "<file>"# --signoff# Invoke "git commit" with --signoff# --author=<author>
Add a test for one of the error conditions added in
938a60d64f (mailmap: clean up read_mailmap error handling,
2012-12-12).
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 9 +++++++++
1 file changed, 9 insertions(+)
@@ -333,6 +333,15 @@ test_expect_success 'mailmap.blob can be missing' 'test_cmpexpectactual'+test_expect_success'mailmap.blob might be the wrong type''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&++git-cmailmap.blob=HEAD:shortlogHEAD>actual2>err&&+test_i18ngrep"mailmap is not a blob"err&&+test_cmpexpectactual+'+ test_expect_success'mailmap.blob defaults to off in non-bare repo''gitinitnon-bare&&(
Expand the comment template for "test_commit" to match that of
"test_commit_bulk" added in b1c36cb849 (test-lib: introduce
test_commit_bulk, 2019-07-02). It has several undocumented options,
which won't all fit on one line. Follow-up commit(s) will document
them.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/test-lib-functions.sh | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
@@ -178,16 +178,14 @@ debug () {GIT_DEBUGGER="${GIT_DEBUGGER}""$@"<&6>&52>&7}-# Call test_commit with the arguments-# [-C <directory>] <message> [<file> [<contents> [<tag>]]]"+# Usage: test_commit [options] <message> [<file> [<contents> [<tag>]]]+# -C <dir>:+# Run all git commands in directory <dir>## This will commit a file with the given contents and the given commit# message, and tag the resulting commit with the given tag name.## <file>, <contents>, and <tag> all default to <message>.-#-# If the first argument is "-C", the second argument is used as a path for-# the git invocations. test_commit(){notick=&&
That we silently ignore missing mailmap.file or mailmap.blob values is
intentional. See 938a60d64f (mailmap: clean up read_mailmap error
handling, 2012-12-12). However, nothing tested for this. Let's do that
by checking that stderr is empty in those cases.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
@@ -309,6 +309,24 @@ test_expect_success 'mailmap.file overrides mailmap.blob' 'test_cmpexpectactual'+test_expect_success'mailmap.file can be missing''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&++test_configmailmap.filenonexistent&&+cat>expect<<-\EOF&&+RepoGuy(1):+initial++nick1(1):+second++EOF+gitshortlogHEAD>actual2>err&&+test_must_be_emptyerr&&+test_cmpexpectactual+'+ test_expect_success'mailmap.blob can be missing''test_when_finished"rm .mailmap"&&cpdefault.map.mailmap&&
@@ -321,7 +339,8 @@ test_expect_success 'mailmap.blob can be missing' 'secondEOF-git-cmailmap.blob=map:nonexistentshortlogHEAD>actual&&+git-cmailmap.blob=map:nonexistentshortlogHEAD>actual2>err&&+test_must_be_emptyerr&&test_cmpexpectactual'
Add support for --author to "test_commit". This will simplify some
current and future tests, one of those is being changed here.
Let's also line-wrap the "git commit" command invocation to make diffs
that add subsequent options easier to add, as they'll only need to add
a new option line.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t7509-commit-authorship.sh | 7 ++-----
t/test-lib-functions.sh | 11 ++++++++++-
2 files changed, 12 insertions(+), 6 deletions(-)
@@ -185,6 +185,8 @@ debug () {# Do not call test_tick before making a commit# --signoff# Invoke "git commit" with --signoff+# --author=<author>+# Invoke "git commit" with --author=<author>## This will commit a file with the given contents and the given commit# message, and tag the resulting commit with the given tag name.
The --notick argument was added in [1] and was followed by --signoff
in [2], but neither of these commits added any documentation for these
options. When -C was added in [3] a comment was added to document it,
but not the other options. Let's document all of these options.
1. 44b85e89d7 (t7003: add test to filter a branch with a commit at
epoch, 2012-07-12),
2. 5ed75e2a3f (cherry-pick: don't forget -s on failure, 2012-09-14).
3. 6f94351b0a (test-lib-functions.sh: teach test_commit -C <dir>,
2016-12-08)
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/test-lib-functions.sh | 4 ++++
1 file changed, 4 insertions(+)
@@ -181,6 +181,10 @@ debug () {# Usage: test_commit [options] <message> [<file> [<contents> [<tag>]]]# -C <dir>:# Run all git commands in directory <dir>+# --notick+# Do not call test_tick before making a commit+# --signoff+# Invoke "git commit" with --signoff## This will commit a file with the given contents and the given commit# message, and tag the resulting commit with the given tag name.
Change a test that used a custom fuzzing function since
bfdfa3d414 (t4203 (mailmap): stop hardcoding commit ids and dates,
2010-10-15) to just use the "blame --porcelain" output instead.
We could use the same pattern as 0ba9c9a0fb (t8008: rely on
rev-parse'd HEAD instead of sha1 value, 2017-07-26) does to do this,
but there wouldn't be any point. We're not trying to test "blame"
output here in general, just that "blame" pays attention to the
mailmap.
So it's sufficient to get the blamed line(s) and authors from the
output, which is much easier with the "--porcelain" option.
It would still be possible for there to be a bug in "blame" such that
it uses the mailmap for its "--porcelain" output, but not the regular
output. Let's test for that simply by checking if specifying the
mailmap changes the output.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 50 +++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 20 deletions(-)
Remove a redundant line in a test added in d20d654fe8 (Change current
mailmap usage to do matching on both name and email of
author/committer., 2009-02-08).
This didn't conceivably test anything useful and is most likely a
copy/paste error.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 1 -
1 file changed, 1 deletion(-)
The --stdin tests setup the "contact" file in the main setup, let's
instead set it up in the test that uses it.
Also refactor the first test so it's obvious that the point of it is
that "check-mailmap" will spew its input as-is when given no
argument. For that one we can just use the "expect" file as-is.
Also add tests for how other "--stdin" cases are handled, e.g. one
where we actually do a mapping.
For the rest of --stdin testing we just assume we're going to get the
same output. We could follow-up and make sure everything's
round-tripped through both --stdin and the file/blob backends, but I
don't think there's much point in that.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 40 ++++++++++++++++++++++++++++++++--------
1 file changed, 32 insertions(+), 8 deletions(-)
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 <redacted>
---
Documentation/gitmailmap.txt | 49 ++++++++++++--------
t/t4203-mailmap.sh | 88 ++++++++++++++++++++++++++++++++++++
2 files changed, 117 insertions(+), 20 deletions(-)
@@ -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@example.com>+Jane Doe <jane@example.com>+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@example.com>+Jane Doe <jane@example.com> <jane@laptop.(none)>+Jane Doe <jane@example.com> <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@company.xx>-nick2 <bugs@company.xx>-nick2 <nick2@company.xx>-santa <me@company.xx>-claus <me@company.xx>-CTO <cto@coompany.xx>+Joe <bugs@example.com>+Jane <bugs@example.com> -------------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@company.xx> <cto@coompany.xx>-Some Dude <some@dude.xx> nick1 <bugs@company.xx>-Other Author <other@author.xx> nick2 <bugs@company.xx>-Other Author <other@author.xx> <nick2@company.xx>-Santa Claus <santa.claus@northpole.xx> <me@company.xx>+Joe R. Developer <joe@example.com>+Jane Doe <jane@example.com> <jane@laptop.(none)>+Jane Doe <jane@example.com> <jane@desktop.(none)>+Joe R. Developer <joe@example.com> Joe <bugs@example.com>+Jane Doe <jane@example.com> Jane <bugs@example.com> ------------
@@ -419,6 +419,94 @@ test_expect_success 'preserve canonical email case' 'test_cmpexpectactual'+test_expect_success'gitmailmap(5) example output: setup''+test_create_repodoc&&+test_commit-Cdoc--author"Joe Developer <joe@example.com>"A&&+test_commit-Cdoc--author"Joe R. Developer <joe@example.com>"B&&+test_commit-Cdoc--author"Jane Doe <jane@example.com>"C&&+test_commit-Cdoc--author"Jane Doe <jane@laptop.(none)>"D&&+test_commit-Cdoc--author"Jane D. <jane@desktop.(none)>"E+'++test_expect_success'gitmailmap(5) example output: example #1''+test_config-Cdocmailmap.file../doc.map&&+cat>doc.map<<-\EOF&&+JoeR.Developer<joe@example.com>+JaneDoe<jane@example.com>+JaneDoe<jane@desktop.(none)>+EOF++cat>expect<<-\EOF&&+AuthorJoeDeveloper<joe@example.com>mapstoJoeR.Developer<joe@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJoeR.Developer<joe@example.com>mapstoJoeR.Developer<joe@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJaneDoe<jane@example.com>mapstoJaneDoe<jane@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJaneDoe<jane@laptop.(none)>mapstoJaneDoe<jane@laptop.(none)>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJaneD<jane@desktop.(none)>mapstoJaneDoe<jane@desktop.(none)>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>+EOF+git-Cdoclog--reverse--pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n">actual&&+test_cmpexpectactual+'++test_expect_success'gitmailmap(5) example output: example #2''+test_config-Cdocmailmap.file../doc.map&&+cat>doc.map<<-\EOF&&+JoeR.Developer<joe@example.com>+JaneDoe<jane@example.com><jane@laptop.(none)>+JaneDoe<jane@example.com><jane@desktop.(none)>+EOF++cat>expect<<-\EOF&&+AuthorJoeDeveloper<joe@example.com>mapstoJoeR.Developer<joe@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJoeR.Developer<joe@example.com>mapstoJoeR.Developer<joe@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJaneDoe<jane@example.com>mapstoJaneDoe<jane@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJaneDoe<jane@laptop.(none)>mapstoJaneDoe<jane@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJaneD<jane@desktop.(none)>mapstoJaneDoe<jane@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>+EOF+git-Cdoclog--reverse--pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n">actual&&+test_cmpexpectactual+'++test_expect_success'gitmailmap(5) example output: example #3''+test_config-Cdocmailmap.file../doc.map&&+cat>>doc.map<<-\EOF&&+JoeR.Developer<joe@example.com>Joe<bugs@example.com>+JaneDoe<jane@example.com>Jane<bugs@example.com>+EOF++test_commit-Cdoc--author"Joe <bugs@example.com>"F&&+test_commit-Cdoc--author"Jane <bugs@example.com>"G&&++cat>>expect<<-\EOF&&++AuthorJoe<bugs@example.com>mapstoJoeR.Developer<joe@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>++AuthorJane<bugs@example.com>mapstoJaneDoe<jane@example.com>+CommitterCOMitter<committer@example.com>mapstoCOMitter<committer@example.com>+EOF+git-Cdoclog--reverse--pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n">actual&&+test_cmpexpectactual+'++ test_expect_success'Shortlog output (complex mapping)''test_configmailmap.filecomplex.map&&cat>complex.map<<-EOF&&
Add a test for mailmap comment syntax. As noted in [1] there was no
test coverage for this. Let's make sure a future change doesn't break
it.
1. https://lore.kernel.org/git/CAN0heSoKYWXqskCR=GPreSHc6twCSo1345WTmiPdrR57XSShhA@mail.gmail.com/
Reported-by: Martin Ågren <redacted>
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
Refactor the mailmap tests to:
* Setup "actual" test files in the body of "test_expect_success"
* Don't have X of "test_expect_success X Y" be an unquoted string.
* Not to carry over test config between tests, and instead use
"test_config".
* Replace various "echo" a line-at-a-time patterns with here-docs.
* Change a case of "log.mailmap=False" to use the lower-case
"false". Both work, but this ends up in git-config's boolean
parsing and these atypical values are tested for elsewhere. Let's
use the lower-case to not draw the reader's attention to this
abnormality.
* Remove commentary asserting that things work a given way in favor
of simply testing for it, i.e. in the case of a .mailmap file
outside of the repository.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 473 ++++++++++++++++++++++++++-------------------
1 file changed, 274 insertions(+), 199 deletions(-)
@@ -66,128 +66,164 @@ test_expect_success 'check-mailmap bogus contact' 'test_must_failgitcheck-mailmapbogus'-cat>expect<<EOF-$GIT_AUTHOR_NAME(1):-initial--nick1(1):-second+test_expect_success'No mailmap''+cat>expect<<-EOF&&+$GIT_AUTHOR_NAME(1):+initial-EOF+nick1(1):+second-test_expect_success'No mailmap''+EOFgitshortlogHEAD>actual&&test_cmpexpectactual'-cat>expect<<\EOF-RepoGuy(1):-initial+test_expect_success'setup default .mailmap''+cat>default.map<<-EOF+RepoGuy<$GIT_AUTHOR_EMAIL>+EOF+'++test_expect_success'test default .mailmap''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&-nick1(1):-second+cat>expect<<-\EOF&&+RepoGuy(1):+initial-EOF+nick1(1):+second-test_expect_success'default .mailmap''-echo"Repo Guy <$GIT_AUTHOR_EMAIL>">.mailmap&&+EOFgitshortlogHEAD>actual&&test_cmpexpectactual'-# Using a mailmap file in a subdirectory of the repo here, but-# could just as well have been a file outside of the repository-cat>expect<<\EOF-InternalGuy(1):-second+test_expect_success'mailmap.file set''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&-RepoGuy(1):-initial+test_configmailmap.fileinternal.map&&+cat>internal.map<<-\EOF&&+InternalGuy<bugs@company.xx>+EOF-EOF-test_expect_success'mailmap.file set''-mkdir-pinternal_mailmap&&-echo"Internal Guy <bugs@company.xx>">internal_mailmap/.mailmap&&-gitconfigmailmap.fileinternal_mailmap/.mailmap&&+cat>expect<<-\EOF&&+InternalGuy(1):+second++RepoGuy(1):+initial++EOFgitshortlogHEAD>actual&&-test_cmpexpectactual+test_cmpexpectactual&&++# The internal_mailmap/.mailmap file is an a subdirectory, but+# as shown here it can also be outside the repository+test_when_finished"rm -rf sub-repo"&&+gitclone.sub-repo&&+(+cdsub-repo&&+cp../.mailmap.&&+gitconfigmailmap.file../internal.map&&+gitshortlogHEAD>actual&&+test_cmp../expectactual+)'-cat>expect<<\EOF-ExternalGuy(1):-initial+test_expect_success'mailmap.file override''+test_configmailmap.fileinternal.map&&+cat>internal.map<<-EOF&&+InternalGuy<bugs@company.xx>+ExternalGuy<$GIT_AUTHOR_EMAIL>+EOF-InternalGuy(1):-second+cat>expect<<-\EOF&&+ExternalGuy(1):+initial-EOF-test_expect_success'mailmap.file override''-echo"External Guy <$GIT_AUTHOR_EMAIL>">>internal_mailmap/.mailmap&&-gitconfigmailmap.fileinternal_mailmap/.mailmap&&+InternalGuy(1):+second++EOFgitshortlogHEAD>actual&&test_cmpexpectactual'-cat>expect<<\EOF-RepoGuy(1):-initial+test_expect_success'mailmap.file non-existent''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&-nick1(1):-second+cat>expect<<-\EOF&&+RepoGuy(1):+initial-EOF+nick1(1):+second-test_expect_success'mailmap.file non-existent''-rminternal_mailmap/.mailmap&&-rmdirinternal_mailmap&&+EOFgitshortlogHEAD>actual&&test_cmpexpectactual'-cat>expect<<\EOF-InternalGuy(1):-second+test_expect_success'name entry after email entry''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&-RepoGuy(1):-initial+test_configmailmap.fileinternal.map&&+cat>internal.map<<-\EOF&&+<bugs@company.xy><bugs@company.xx>+InternalGuy<bugs@company.xx>+EOF-EOF+cat>expect<<-\EOF&&+InternalGuy(1):+second++RepoGuy(1):+initial++EOF-test_expect_success'name entry after email entry''-mkdir-pinternal_mailmap&&-echo"<bugs@company.xy> <bugs@company.xx>">internal_mailmap/.mailmap&&-echo"Internal Guy <bugs@company.xx>">>internal_mailmap/.mailmap&&gitshortlogHEAD>actual&&test_cmpexpectactual'-cat>expect<<\EOF-InternalGuy(1):-second+test_expect_success'name entry after email entry, case-insensitive''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&-RepoGuy(1):-initial+test_configmailmap.fileinternal.map&&+cat>internal.map<<-\EOF&&+<bugs@company.xy><bugs@company.xx>+InternalGuy<BUGS@Company.xx>+EOF-EOF+cat>expect<<-\EOF&&+InternalGuy(1):+second++RepoGuy(1):+initial++EOF-test_expect_success'name entry after email entry, case-insensitive''-mkdir-pinternal_mailmap&&-echo"<bugs@company.xy> <bugs@company.xx>">internal_mailmap/.mailmap&&-echo"Internal Guy <BUGS@Company.xx>">>internal_mailmap/.mailmap&&gitshortlogHEAD>actual&&test_cmpexpectactual'-cat>expect<<EOF-$GIT_AUTHOR_NAME(1):-initial+test_expect_success'No mailmap files, but configured''+cat>expect<<-EOF&&+$GIT_AUTHOR_NAME(1):+initial-nick1(1):-second+nick1(1):+second-EOF-test_expect_success'No mailmap files, but configured''-rm-f.mailmapinternal_mailmap/.mailmap&&+EOFgitshortlogHEAD>actual&&test_cmpexpectactual'
@@ -205,11 +241,16 @@ test_expect_success 'setup mailmap blob tests' 'printf"Tricky Guy <$GIT_AUTHOR_EMAIL>">no-newline&&gitaddjust-bugsbothno-newline&&gitcommit-m"my mailmaps"&&-echo"Repo Guy <$GIT_AUTHOR_EMAIL>">.mailmap&&-echo"Internal Guy <$GIT_AUTHOR_EMAIL>">internal.map++cat>internal.map<<-EOF+InternalGuy<$GIT_AUTHOR_EMAIL>+EOF' test_expect_success'mailmap.blob set''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&+cat>expect<<-\EOF&&BlobGuy(1):second
@@ -250,6 +294,9 @@ test_expect_success 'mailmap.file overrides mailmap.blob' '' test_expect_success'mailmap.blob can be missing''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&+cat>expect<<-\EOF&&RepoGuy(1):initial
@@ -267,11 +314,15 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' '(cdnon-bare&&test_commitone.mailmap"Fake Name <$GIT_AUTHOR_EMAIL>"&&-echo" 1 Fake Name">expect&&+cat>expect<<-\EOF&&+1FakeName+EOFgitshortlog-nsHEAD>actual&&test_cmpexpectactual&&rm.mailmap&&-echo" 1 $GIT_AUTHOR_NAME">expect&&+cat>expect<<-EOF&&+1$GIT_AUTHOR_NAME+EOFgitshortlog-nsHEAD>actual&&test_cmpexpectactual)
@@ -281,7 +332,9 @@ test_expect_success 'mailmap.blob defaults to HEAD:.mailmap in bare repo' 'gitclone--barenon-barebare&&(cdbare&&-echo" 1 Fake Name">expect&&+cat>expect<<-\EOF&&+1FakeName+EOFgitshortlog-nsHEAD>actual&&test_cmpexpectactual)
@@ -300,50 +353,46 @@ test_expect_success 'mailmap.blob can handle blobs without trailing newline' 'test_cmpexpectactual'-test_expect_success'cleanup after mailmap.blob tests''-rm-f.mailmap-'- test_expect_success'single-character name''-echo" 1 A <$GIT_AUTHOR_EMAIL>">expect&&-echo" 1 nick1 <bugs@company.xx>">>expect&&-echo"A <$GIT_AUTHOR_EMAIL>">.mailmap&&test_when_finished"rm .mailmap"&&+cat>.mailmap<<-EOF&&+A<$GIT_AUTHOR_EMAIL>+EOF++cat>expect<<-EOF&&+1A<$GIT_AUTHOR_EMAIL>+1nick1<bugs@company.xx>+EOFgitshortlog-esHEAD>actual&&test_cmpexpectactual' test_expect_success'preserve canonical email case''-echo" 1 $GIT_AUTHOR_NAME <AUTHOR@example.com>">expect&&-echo" 1 nick1 <bugs@company.xx>">>expect&&-echo"<AUTHOR@example.com> <$GIT_AUTHOR_EMAIL>">.mailmap&&test_when_finished"rm .mailmap"&&+cat>.mailmap<<-EOF&&+<AUTHOR@example.com><$GIT_AUTHOR_EMAIL>+EOF++cat>expect<<-EOF&&+1$GIT_AUTHOR_NAME<AUTHOR@example.com>+1nick1<bugs@company.xx>+EOFgitshortlog-esHEAD>actual&&test_cmpexpectactual'-# Extended mailmap configurations should give us the following output for shortlog-cat>expect<<EOF-$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>(1):-initial--CTO<cto@company.xx>(1):-seventh--OtherAuthor<other@author.xx>(2):-third-fourth--SantaClaus<santa.claus@northpole.xx>(2):-fifth-sixth--SomeDude<some@dude.xx>(1):-second--EOF- test_expect_success'Shortlog output (complex mapping)''+test_configmailmap.filecomplex.map&&+cat>complex.map<<-EOF&&+Committed<$GIT_COMMITTER_EMAIL>+<cto@company.xx><cto@coompany.xx>+SomeDude<some@dude.xx>nick1<bugs@company.xx>+OtherAuthor<other@author.xx>nick2<bugs@company.xx>+OtherAuthor<other@author.xx><nick2@company.xx>+SantaClaus<santa.claus@northpole.xx><me@company.xx>+SantaClaus<santa.claus@northpole.xx><me@company.xx>+EOF+echothree>>one&&gitaddone&&test_tick&&
@@ -369,103 +418,119 @@ test_expect_success 'Shortlog output (complex mapping)' 'test_tick&&gitcommit--author"CTO <cto@coompany.xx>"-mseventh&&-mkdir-pinternal_mailmap&&-echo"Committed <$GIT_COMMITTER_EMAIL>">internal_mailmap/.mailmap&&-echo"<cto@company.xx> <cto@coompany.xx>">>internal_mailmap/.mailmap&&-echo"Some Dude <some@dude.xx> nick1 <bugs@company.xx>">>internal_mailmap/.mailmap&&-echo"Other Author <other@author.xx> nick2 <bugs@company.xx>">>internal_mailmap/.mailmap&&-echo"Other Author <other@author.xx> <nick2@company.xx>">>internal_mailmap/.mailmap&&-echo"Santa Claus <santa.claus@northpole.xx> <me@company.xx>">>internal_mailmap/.mailmap&&-echo"Santa Claus <santa.claus@northpole.xx> <me@company.xx>">>internal_mailmap/.mailmap&&+cat>expect<<-EOF&&+$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>(1):+initial++CTO<cto@company.xx>(1):+seventh++OtherAuthor<other@author.xx>(2):+third+fourth++SantaClaus<santa.claus@northpole.xx>(2):+fifth+sixth++SomeDude<some@dude.xx>(1):+second++EOFgitshortlog-eHEAD>actual&&test_cmpexpectactual'-# git log with --pretty format which uses the name and email mailmap placemarkers-cat>expect<<EOF-AuthorCTO<cto@coompany.xx>mapstoCTO<cto@company.xx>-Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>+test_expect_success'Log output (complex mapping)''+test_configmailmap.filecomplex.map&&-Authorclaus<me@company.xx>mapstoSantaClaus<santa.claus@northpole.xx>-Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>+cat>expect<<-EOF&&+AuthorCTO<cto@coompany.xx>mapstoCTO<cto@company.xx>+Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>-Authorsanta<me@company.xx>mapstoSantaClaus<santa.claus@northpole.xx>-Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>+Authorclaus<me@company.xx>mapstoSantaClaus<santa.claus@northpole.xx>+Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>-Authornick2<nick2@company.xx>mapstoOtherAuthor<other@author.xx>-Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>+Authorsanta<me@company.xx>mapstoSantaClaus<santa.claus@northpole.xx>+Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>-Authornick2<bugs@company.xx>mapstoOtherAuthor<other@author.xx>-Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>+Authornick2<nick2@company.xx>mapstoOtherAuthor<other@author.xx>+Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>-Authornick1<bugs@company.xx>mapstoSomeDude<some@dude.xx>-Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>+Authornick2<bugs@company.xx>mapstoOtherAuthor<other@author.xx>+Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>-Author$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>mapsto$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>-Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>-EOF+Authornick1<bugs@company.xx>mapstoSomeDude<some@dude.xx>+Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>++Author$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>mapsto$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>+Committer$GIT_COMMITTER_NAME<$GIT_COMMITTER_EMAIL>mapstoCommitted<$GIT_COMMITTER_EMAIL>+EOF-test_expect_success'Log output (complex mapping)''gitlog--pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n">actual&&test_cmpexpectactual'-cat>expect<<EOF-Authoremailcto@coompany.xxhaslocal-partcto-Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME+test_expect_success'Log output (local-part email address)''+cat>expect<<-EOF&&+Authoremailcto@coompany.xxhaslocal-partcto+Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME-Authoremailme@company.xxhaslocal-partme-Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME+Authoremailme@company.xxhaslocal-partme+Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME-Authoremailme@company.xxhaslocal-partme-Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME+Authoremailme@company.xxhaslocal-partme+Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME-Authoremailnick2@company.xxhaslocal-partnick2-Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME+Authoremailnick2@company.xxhaslocal-partnick2+Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME-Authoremailbugs@company.xxhaslocal-partbugs-Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME+Authoremailbugs@company.xxhaslocal-partbugs+Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME-Authoremailbugs@company.xxhaslocal-partbugs-Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME+Authoremailbugs@company.xxhaslocal-partbugs+Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME-Authoremailauthor@example.comhaslocal-partauthor-Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME-EOF+Authoremailauthor@example.comhaslocal-partauthor+Committeremail$GIT_COMMITTER_EMAILhaslocal-part$TEST_COMMITTER_LOCALNAME+EOF-test_expect_success'Log output (local-part email address)''gitlog--pretty=format:"Author email %ae has local-part %al%nCommitter email %ce has local-part %cl%n">actual&&test_cmpexpectactual'-cat>expect<<EOF-Author:CTO<cto@company.xx>-Author:SantaClaus<santa.claus@northpole.xx>-Author:SantaClaus<santa.claus@northpole.xx>-Author:OtherAuthor<other@author.xx>-Author:OtherAuthor<other@author.xx>-Author:SomeDude<some@dude.xx>-Author:$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>-EOF- test_expect_success'Log output with --use-mailmap''+test_configmailmap.filecomplex.map&&++cat>expect<<-EOF&&+Author:CTO<cto@company.xx>+Author:SantaClaus<santa.claus@northpole.xx>+Author:SantaClaus<santa.claus@northpole.xx>+Author:OtherAuthor<other@author.xx>+Author:OtherAuthor<other@author.xx>+Author:SomeDude<some@dude.xx>+Author:$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>+EOF+gitlog--use-mailmap|grepAuthor>actual&&test_cmpexpectactual'-cat>expect<<EOF-Author:CTO<cto@company.xx>-Author:SantaClaus<santa.claus@northpole.xx>-Author:SantaClaus<santa.claus@northpole.xx>-Author:OtherAuthor<other@author.xx>-Author:OtherAuthor<other@author.xx>-Author:SomeDude<some@dude.xx>-Author:$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>-EOF- test_expect_success'Log output with log.mailmap''+test_configmailmap.filecomplex.map&&++cat>expect<<-EOF&&+Author:CTO<cto@company.xx>+Author:SantaClaus<santa.claus@northpole.xx>+Author:SantaClaus<santa.claus@northpole.xx>+Author:OtherAuthor<other@author.xx>+Author:OtherAuthor<other@author.xx>+Author:SomeDude<some@dude.xx>+Author:$GIT_AUTHOR_NAME<$GIT_AUTHOR_EMAIL>+EOF+git-clog.mailmap=Truelog|grepAuthor>actual&&test_cmpexpectactual'
Change these tests to use the preferred whitespace around ">",
"<<-EOF" etc. This is an initial step in larger and more meaningful
refactoring of the file, which makes a subsequent commit easier to
read.
I'm not changing the whitespace of "echo <str> > file" patterns to
"echo <str> >file" because all of those will be changed to here-docs
in a subsequent commit.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
Mentioning the comment syntax and blank line support first is in line
with how "git help config" describes its format. See
b8936cf060 (config.txt grammar, typo, and asciidoc fixes, 2006-06-08)
for the paragraph I'm copying & amending from its documentation.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
Documentation/gitmailmap.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -23,6 +23,9 @@ canonical real names and email addresses. SYNTAX ------+The '#' character begins a comment to the end of line, blank lines+are ignored.+ In the simple form, each line in the file consists of the canonical real name of an author, whitespace, and an email address used in the commit (enclosed by '<' and '>') to map to the name. For example:
@@ -94,8 +97,6 @@ Other Author <other@author.xx> <nick2@company.xx> Santa Claus <santa.claus@northpole.xx> <me@company.xx> -------------Use hash '#' for comments that are either on their own line, or after-the email address. SEE ALSO
Add a passing mention of the mailmap.file and mailmap.blob
configuration options. Before this addition a reader of the
"check-mailmap" manpage would have no idea that a custom map could be
specified, unless they'd happen to e.g. come across it in the "config"
manpage first.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
Documentation/git-check-mailmap.txt | 7 +++++++
1 file changed, 7 insertions(+)
@@ -36,6 +36,13 @@ name is provided or known to the 'mailmap', ``Name $$<user@host>$$'' is printed; otherwise only ``$$<user@host>$$'' is printed.+CONFIGURATION+-------------++See `mailmap.file` and `mailmap.blob` in linkgit:git-config[1] for how+to specify a custom `.mailmap` target file or object.++ MAPPING AUTHORS ---------------
Create a gitmailmap(5) page similar to how .gitmodules and .gitignore
have their own pages at gitmodules(5) and gitignore(5). Now instead of
"check-mailmap", "blame" and "shortlog" documentation including the
description of the format we link to one canonical place.
This makes things easier for readers, since in our manpage or
web-based[1] output it's not clear that the "MAPPING AUTHORS" sections
aren't subtly different, as opposed to just included.
1. https://git-scm.com/docs/git-check-mailmap
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
Documentation/Makefile | 1 +
Documentation/git-blame.txt | 2 +-
Documentation/git-check-mailmap.txt | 2 +-
Documentation/git-shortlog.txt | 6 +---
Documentation/{mailmap.txt => gitmailmap.txt} | 33 +++++++++++++++++++
command-list.txt | 1 +
6 files changed, 38 insertions(+), 7 deletions(-)
rename Documentation/{mailmap.txt => gitmailmap.txt} (88%)
@@ -226,7 +226,7 @@ commit commentary), a blame viewer will not care. MAPPING AUTHORS ----------------include::mailmap.txt[]+See linkgit:gitmailmap[5]. SEE ALSO
@@ -111,11 +111,7 @@ include::rev-list-options.txt[] MAPPING AUTHORS ----------------The `.mailmap` feature is used to coalesce together commits by the same-person in the shortlog, where their name and/or email address was-spelled differently.--include::mailmap.txt[]+See linkgit:gitmailmap[5]. GIT ---
diff --git a/Documentation/mailmap.txt b/Documentation/gitmailmap.txtsimilarity index 88%rename from Documentation/mailmap.txtrename to Documentation/gitmailmap.txtindex 4a8c276529..8b07f9c5d7 100644--- a/Documentation/mailmap.txt+++ b/Documentation/gitmailmap.txt
@@ -1,9 +1,28 @@+gitmailmap(5)+=============++NAME+----+gitmailmap - Map author/committer names and/or E-Mail addresses++SYNOPSIS+--------+$GIT_WORK_DIR/.mailmap+++DESCRIPTION+-----------+ If the file `.mailmap` exists at the toplevel of the repository, or at the location pointed to by the mailmap.file or mailmap.blob configuration options, it is used to map author and committer names and email addresses to canonical real names and email addresses.++SYNTAX+------+ In the simple form, each line in the file consists of the canonical real name of an author, whitespace, and an email address used in the commit (enclosed by '<' and '>') to map to the name. For example:
@@ -27,6 +46,10 @@ commit matching the specified commit email address, and: which allows mailmap to replace both the name and the email of a commit matching both the specified commit name and email address.++EXAMPLES+--------+ Example 1: Your history contains commits by two authors, Jane and Joe, whose names appear in the repository under several forms:
@@ -73,3 +96,13 @@ Santa Claus <santa.claus@northpole.xx> <me@company.xx> Use hash '#' for comments that are either on their own line, or after the email address.+++SEE ALSO+--------+linkgit:git-check-mailmap[1]+++GIT+---+Part of the linkgit:git[1] suite
Just a "small" addition to v1, now with 21 extra patches. While this
is a large series, it should be relatively easy to read and
non-contentious. Mainly
* We now have a "man 5 gitmailmap", rather than including the format
description in N places.
* Lots of extra tests & improvements to modernize existing tests to
make them more reliable and easier to read.
* Rewrote the example section in the documentation to be more
understandable, and you can now follow it along with tests that
mirror it.
* Document that mailmap name/email matching is case-insensitive.
* Document & test for the comment syntax.
* Add an "--author" and "--append" argument to test_commit, which is
used by the mailmap tests, but also a few other tests (just as an
example). This is why the series modifies a few non-mailmap tests.
Ævar Arnfjörð Bjarmason (22):
mailmap doc: create a new "gitmailmap(5)" man page
mailmap doc: quote config variables `like.this`
check-mailmap doc: note config options
mailmap doc: start by mentioning the comment syntax
mailmap tests: use our preferred whitespace syntax
mailmap tests: modernize syntax & test idioms
mailmap tests: improve --stdin tests
mailmap tests: remove redundant entry in test
mailmap tests: add a test for "not a blob" error
mailmap tests: get rid of overly complex blame fuzzing
mailmap: test for silent exiting on missing file/blob
test-lib functions: expand "test_commit" comment template
test-lib functions: document arguments to test_commit
test-lib functions: add --author support to test_commit
test-lib functions: add an --append option to test_commit
tests: refactor a few tests to use "test_commit --append"
mailmap doc + tests: add better examples & test them
mailmap tests: add a test for comment syntax
mailmap tests: add tests for whitespace syntax
mailmap tests: add tests for empty "<>" syntax
mailmap doc + tests: document and test for case-insensitivity
shortlog: remove unused(?) "repo-abbrev" feature
Documentation/Makefile | 1 +
Documentation/git-blame.txt | 2 +-
Documentation/git-check-mailmap.txt | 9 +-
Documentation/git-shortlog.txt | 6 +-
Documentation/gitmailmap.txt | 123 +++++
Documentation/mailmap.txt | 75 ---
builtin/blame.c | 2 +-
builtin/check-mailmap.c | 2 +-
builtin/commit.c | 2 +-
builtin/log.c | 2 +-
builtin/shortlog.c | 16 +-
command-list.txt | 1 +
mailmap.c | 48 +-
mailmap.h | 2 +-
pretty.c | 2 +-
shortlog.h | 1 -
t/t1412-reflog-loop.sh | 7 +-
t/t2012-checkout-last.sh | 12 +-
t/t4203-mailmap.sh | 825 +++++++++++++++++++---------
t/t7509-commit-authorship.sh | 7 +-
t/t7810-grep.sh | 18 +-
t/test-lib-functions.sh | 37 +-
22 files changed, 771 insertions(+), 429 deletions(-)
create mode 100644 Documentation/gitmailmap.txt
delete mode 100644 Documentation/mailmap.txt
--
2.29.2.222.g5d2a92d10f8
Quote the mailmap.file and mailmap.blob configuration variables as
`mailmap.file` and `mailmap.blob`, and link to git-config(1). This is
in line with the preferred way of doing this in the rest of our
documentation.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
Documentation/gitmailmap.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -14,8 +14,8 @@ DESCRIPTION ----------- If the file `.mailmap` exists at the toplevel of the repository, or at-the location pointed to by the mailmap.file or mailmap.blob-configuration options, it+the location pointed to by the `mailmap.file` or `mailmap.blob`+configuration options (see linkgit:git-config[1]), it is used to map author and committer names and email addresses to canonical real names and email addresses.
From: Junio C Hamano <hidden> Date: 2021-01-12 22:35:15
Ævar Arnfjörð Bjarmason [off-list ref] writes:
Add support for --author to "test_commit". This will simplify some
current and future tests, one of those is being changed here.
Let's also line-wrap the "git commit" command invocation to make diffs
that add subsequent options easier to add, as they'll only need to add
a new option line.
An approach along the lines of ...
NUM="[0-9][0-9]*"
sed -n -e "s/^author //p" \
-e "s/^$OID_REGEX \($NUM $NUM $NUM\)$/\1/p"
... would allow you to drop "cut" and also not assume that names do
not have more than 3 tokens.
From: Junio C Hamano <hidden> Date: 2021-01-12 22:35:15
Ævar Arnfjörð Bjarmason [off-list ref] writes:
Add a test for one of the error conditions added in
938a60d64f (mailmap: clean up read_mailmap error handling,
2012-12-12).
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/t4203-mailmap.sh | 9 +++++++++
1 file changed, 9 insertions(+)
Nice to see a patch that tries to be careful, like this one.
@@ -333,6 +333,15 @@ test_expect_success 'mailmap.blob can be missing' 'test_cmpexpectactual'+test_expect_success'mailmap.blob might be the wrong type''+test_when_finished"rm .mailmap"&&+cpdefault.map.mailmap&&++git-cmailmap.blob=HEAD:shortlogHEAD>actual2>err&&+test_i18ngrep"mailmap is not a blob"err&&+test_cmpexpectactual+'+ test_expect_success'mailmap.blob defaults to off in non-bare repo''gitinitnon-bare&&(
@@ -185,6 +185,8 @@ debug () {# Do not call test_tick before making a commit# --signoff# Invoke "git commit" with --signoff+# --author=<author>
The usage shows that you have to specify the author argument with an
equal sign...
quoted hunk
+# Invoke "git commit" with --author=<author>
#
# This will commit a file with the given contents and the given commit
# message, and tag the resulting commit with the given tag name.
While you're doing test cleanup, here's another suggestion: we should
break all these pipes where git is in the upstream of a pipe. The return
code of a pipe comes from the last thing run which means if git outputs
correctly but then somehow fails after, we won't detect the failure.
In general, I've stopped my crusade against these because it seems like
it's more noise than it's worth in most cases but in this case, since
we're exercising mailmap codepaths that aren't tested in other test
cases, this pipe could plausibly hide a failure that isn't seen
anywhere else.
Thanks,
Denton
From: Philippe Blain <hidden> Date: 2021-01-14 17:42:04
Hi Ævar,
Le 2021-01-12 à 15:17, Ævar Arnfjörð Bjarmason a écrit :
Create a gitmailmap(5) page similar to how .gitmodules and .gitignore
have their own pages at gitmodules(5) and gitignore(5). Now instead of
"check-mailmap", "blame" and "shortlog" documentation including the
description of the format we link to one canonical place.
This makes things easier for readers, since in our manpage or
web-based[1] output it's not clear that the "MAPPING AUTHORS" sections
aren't subtly different, as opposed to just included.
1. https://git-scm.com/docs/git-check-mailmap
diff --git a/Documentation/mailmap.txt b/Documentation/gitmailmap.txtsimilarity index 88%rename from Documentation/mailmap.txtrename to Documentation/gitmailmap.txtindex 4a8c276529..8b07f9c5d7 100644--- a/Documentation/mailmap.txt+++ b/Documentation/gitmailmap.txt
This should be GIT_WORK_TREE, gitmodules(5) is wrong as GIT_WORK_DIR
does not exists (my series at [1] fixes this).
Also, if you feel like this new guide should be featured in the "Guides" column
at git-scm.com/docs, I encourage you to submit a PR to the website. Though
I think for this specific guide, simply having it listed in git(1), linked from the
"All guides..." link at the bottom of that column, is sufficient.
Cheers,
Philippe.
[1] https://lore.kernel.org/git/pull.942.v2.git.git.1609695736001.gitgitgadget@gmail.com/
From: Denton Liu <hidden> Date: 2021-01-14 23:03:41
A couple of small test cleanups that can be applied on top of
'ab/mailmap'.
Denton Liu (2):
test-lib-functions.sh: fix usage for test_commit()
t4203: stop losing return codes of git commands
t/t4203-mailmap.sh | 21 ++++++++++++++-------
t/test-lib-functions.sh | 4 ++--
2 files changed, 16 insertions(+), 9 deletions(-)
--
2.30.0.284.gd98b1dd5ea
From: Denton Liu <hidden> Date: 2021-01-14 23:03:57
The usage comment for test_commit() shows that the --author option
should be given as `--author=<author>`. However, this is incorrect as it
only works when given as `--author <author>`. Correct this erroneous
text.
Also, for the sake of correctness, fix the description as well since we
invoke `git commit` with `--author <author>`, not `--author=<author>`.
Signed-off-by: Denton Liu <redacted>
---
t/test-lib-functions.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -188,8 +188,8 @@ debug () {# "<file>"# --signoff# Invoke "git commit" with --signoff-# --author=<author>-# Invoke "git commit" with --author=<author>+# --author <author>+# Invoke "git commit" with --author <author>## This will commit a file with the given contents and the given commit# message, and tag the resulting commit with the given tag name.
From: Denton Liu <hidden> Date: 2021-01-14 23:03:57
In a pipe, only the return code of the last command is used. Thus, all
other commands will have their return codes masked. Rewrite pipes so
that there are no git commands upstream so that their failure is
reported.
Signed-off-by: Denton Liu <redacted>
---
t/t4203-mailmap.sh | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
@@ -690,7 +694,8 @@ test_expect_success 'Grep author with --use-mailmap' 'Author:SantaClaus<santa.claus@northpole.xx>Author:SantaClaus<santa.claus@northpole.xx>EOF-gitlog--use-mailmap--authorSanta|grepAuthor>actual&&+gitlog--use-mailmap--authorSanta>log&&+grepAuthorlog>actual&&test_cmpexpectactual'
@@ -702,13 +707,15 @@ test_expect_success 'Grep author with log.mailmap' 'Author:SantaClaus<santa.claus@northpole.xx>EOF-git-clog.mailmap=Truelog--authorSanta|grepAuthor>actual&&+git-clog.mailmap=Truelog--authorSanta>log&&+grepAuthorlog>actual&&test_cmpexpectactual' test_expect_success'log.mailmap is true by default these days''test_configmailmap.filecomplex.map&&-gitlog--authorSanta|grepAuthor>actual&&+gitlog--authorSanta>log&&+grepAuthorlog>actual&&test_cmpexpectactual'
The usage comment for test_commit() shows that the --author option
should be given as `--author=<author>`. However, this is incorrect as it
only works when given as `--author <author>`. Correct this erroneous
text.
Also, for the sake of correctness, fix the description as well since we
invoke `git commit` with `--author <author>`, not `--author=<author>`.
LGTM. Thanks for fixing this.
FWIW I was planning to make it just support --author=*, the
test_commit_bulk() function just below that does that, I think I copied
its doc template, but then used test_commit's existing pattern for
options parsing.
But this works just as well, and is easier :)
@@ -188,8 +188,8 @@ debug () {# "<file>"# --signoff# Invoke "git commit" with --signoff-# --author=<author>-# Invoke "git commit" with --author=<author>+# --author <author>+# Invoke "git commit" with --author <author>## This will commit a file with the given contents and the given commit# message, and tag the resulting commit with the given tag name.
In a pipe, only the return code of the last command is used. Thus, all
other commands will have their return codes masked. Rewrite pipes so
that there are no git commands upstream so that their failure is
reported.
From: Philippe Blain <hidden> Date: 2021-01-15 03:29:10
gitmailmap(5) uses 'GIT_WORK_DIR' to refer to the root of the
repository, but this environment variable does not exist.
Use the correct spelling for that variable, 'GIT_WORK_TREE'.
Signed-off-by: Philippe Blain <redacted>
---
Documentation/gitmailmap.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)