Skip to contentSkip to conversation

git-shortlog: make common repository prefix configurable with .mailmap

PATCH In review Junio C Hamano 7 participants 51 messages Aug 11, 2016 – Jan 26, 2021 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 git-shortlog: make common repository prefix configurable with .mailmap

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.

---
 builtin-shortlog.c    |   24 ++++++++++++++++++++++--
 contrib/mailmap.linux |    2 ++
 2 files changed, 24 insertions(+), 2 deletions(-)
builtin-shortlog.c +22 -2
index bdd952c..b5b13de 100644
@@ -9,6 +9,8 @@
 static const char shortlog_usage[] =
 "git-shortlog [-n] [-s] [<commit-id>... ]";
 
+static char *common_repo_prefix;
+
 static int compare_by_number(const void *a1, const void *a2)
 {
 	const struct path_list_item *i1 = a1, *i2 = a2;
@@ -35,8 +37,26 @@ static int read_mailmap(const char *filename)
 		char *end_of_name, *left_bracket, *right_bracket;
 		char *name, *email;
 		int i;
-		if (buffer[0] == '#')
+		if (buffer[0] == '#') {
+			static const char abbrev[] = "# repo-abbrev:";
+			int abblen = sizeof(abbrev) - 1;
+			int len = strlen(buffer);
+
+			if (len && buffer[len - 1] == '\n')
+				buffer[--len] = 0;
+			if (!strncmp(buffer, abbrev, abblen)) {
+				char *cp;
+
+				if (common_repo_prefix)
+					free(common_repo_prefix);
+				common_repo_prefix = xmalloc(len);
+
+				for (cp = buffer + abblen; isspace(*cp); cp++)
+					; /* nothing */
+				strcpy(common_repo_prefix, cp);
+			}
 			continue;
+		}
 		if ((left_bracket = strchr(buffer, '<')) == NULL)
 			continue;
 		if ((right_bracket = strchr(left_bracket + 1, '>')) == NULL)
@@ -87,7 +107,7 @@ static void insert_author_oneline(struct path_list *list,
 		const char *author, int authorlen,
 		const char *oneline, int onelinelen)
 {
-	const char *dot3 = "/pub/scm/linux/kernel/git/";
+	const char *dot3 = common_repo_prefix;
 	char *buffer, *p;
 	struct path_list_item *item;
 	struct path_list *onelines;
contrib/mailmap.linux +2 -0
index 83927c9..e4907f8 100644
@@ -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 <[email protected]>
 Andreas Herrmann <[email protected]>
 Andrew Morton <[email protected]>
Signature · 1 line
1.4.4.1.g61fba
#1 lore raw

PATCH 1/1 shortlog: remove unused(?) "repo-abbrev" feature

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 [email protected]: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/[email protected]/
5. https://lore.kernel.org/lkml/[email protected]/
6. https://lore.kernel.org/lkml/CAHk-=wg1+kf1AVzXA-RQX0zjM6t9J2Kay9xyuNqcFHWV-y5ZYw@mail.gmail.com/

---

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(-)
builtin/blame.c +1 -1
index 6f7e32411a8..712ae8e7425 100644
@@ -1151,7 +1151,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 	sb.xdl_opts = xdl_opts;
 	sb.no_whole_file_rename = no_whole_file_rename;
 
-	read_mailmap(&mailmap, NULL);
+	read_mailmap(&mailmap);
 
 	sb.found_guilty_entry = &found_guilty_entry;
 	sb.found_guilty_entry_data = &pi;
builtin/check-mailmap.c +1 -1
index cdce144f3b7..7dc47e47932 100644
@@ -47,7 +47,7 @@ int cmd_check_mailmap(int argc, const char **argv, const char *prefix)
 	if (argc == 0 && !use_stdin)
 		die(_("no contacts specified"));
 
-	read_mailmap(&mailmap, NULL);
+	read_mailmap(&mailmap);
 
 	for (i = 0; i < argc; ++i)
 		check_mailmap(&mailmap, argv[i]);
builtin/commit.c +1 -1
index 505fe60956d..739110c5a7f 100644
@@ -1039,7 +1039,7 @@ static const char *find_author_by_nickname(const char *name)
 	av[++ac] = NULL;
 	setup_revisions(ac, av, &revs, NULL);
 	revs.mailmap = &mailmap;
-	read_mailmap(revs.mailmap, NULL);
+	read_mailmap(revs.mailmap);
 
 	if (prepare_revision_walk(&revs))
 		die(_("revision walk setup failed"));
builtin/log.c +1 -1
index bd6ff4f9f95..4ee81bc976d 100644
@@ -230,7 +230,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 
 	if (mailmap) {
 		rev->mailmap = xcalloc(1, sizeof(struct string_list));
-		read_mailmap(rev->mailmap, NULL);
+		read_mailmap(rev->mailmap);
 	}
 
 	if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
builtin/shortlog.c +2 -14
index c52e4ccd19a..e7c21ab6201 100644
@@ -61,8 +61,7 @@ static void insert_one_record(struct shortlog *log,
 	if (log->summary)
 		item->util = (void *)(UTIL_TO_INT(item) + 1);
 	else {
-		const char *dot3 = log->common_repo_prefix;
-		char *buffer, *p;
+		char *buffer;
 		struct strbuf subject = STRBUF_INIT;
 		const char *eol;
 
@@ -82,17 +81,6 @@ static void insert_one_record(struct shortlog *log,
 		format_subject(&subject, oneline, " ");
 		buffer = strbuf_detach(&subject, NULL);
 
-		if (dot3) {
-			int dot3len = strlen(dot3);
-			if (dot3len > 5) {
-				while ((p = strstr(buffer, dot3)) != NULL) {
-					int taillen = strlen(p) - dot3len;
-					memcpy(p, "/.../", 5);
-					memmove(p + 5, p + dot3len, taillen + 1);
-				}
-			}
-		}
-
 		if (item->util == NULL)
 			item->util = xcalloc(1, sizeof(struct string_list));
 		string_list_append(item->util, buffer);
@@ -342,7 +330,7 @@ void shortlog_init(struct shortlog *log)
 {
 	memset(log, 0, sizeof(*log));
 
-	read_mailmap(&log->mailmap, &log->common_repo_prefix);
+	read_mailmap(&log->mailmap);
 
 	log->list.strdup_strings = 1;
 	log->wrap = DEFAULT_WRAPLEN;
mailmap.c +11 -36

100 lines not on this page · raw message

mailmap.h +1 -1
index d0e65646cb5..7e99fccb46c 100644
@@ -3,7 +3,7 @@
 
 struct string_list;
 
-int read_mailmap(struct string_list *map, char **repo_abbrev);
+int read_mailmap(struct string_list *map);
 void clear_mailmap(struct string_list *map);
 
 int map_user(struct string_list *map,
pretty.c +1 -1
index 7a7708a0ea7..fe0a66623e3 100644
@@ -679,7 +679,7 @@ static int mailmap_name(const char **email, size_t *email_len,
 	static struct string_list *mail_map;
 	if (!mail_map) {
 		mail_map = xcalloc(1, sizeof(*mail_map));
-		read_mailmap(mail_map, NULL);
+		read_mailmap(mail_map);
 	}
 	return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
 }
shortlog.h +0 -1
index 64be879b241..3f7e9aabcae 100644
@@ -23,7 +23,6 @@ struct shortlog {
 	} groups;
 	struct string_list trailers;
 
-	char *common_repo_prefix;
 	int email;
 	struct string_list mailmap;
 	FILE *file;
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#2 lore raw

Re: [PATCH] shortlog: remove unused(?) "repo-abbrev" feature

Quoted 4 lines · Ævar Arnfjörð Bjarmason

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

#3 lore raw

PATCH 1/1 mailmap: remove the "repo-abbrev" comment

Remove the magical "repo-abbrev" comment added when this file was introduced in e0ab1ec9fcd3 ([PATCH] add .mailmap for proper git-shortlog output, 2007-02-14).

It's been an undocumented feature of git-shortlog(1), originally added to git for Linus's use. Since then he's no longer using it[1], and I've removed the feature in git.git's 4e168333a87 (shortlog: remove unused(?) "repo-abbrev" feature, 2021-01-12). It's on the "master" branch, but not yet in a release version.

Let's also remove it from linux.git, both as a heads-up to any potential users of it in linux.git whose use would be broken sooner than later by git itself, and because it'll eventually be entirely redundant.

1. https://lore.kernel.org/git/CAHk-=wixHyBKZVUcxq+NCWMbkrX0xnppb7UCopRWw1+oExYpYw@mail.gmail.com/

---
 .mailmap | 3 ---
 1 file changed, 3 deletions(-)
.mailmap +0 -3
index b1ab0129c7d6..cc4e91d3075e 100644
@@ -9,9 +9,6 @@
 #
 # Please keep this list dictionary sorted.
 #
-# This comment is parsed by git-shortlog:
-# repo-abbrev: /pub/scm/linux/kernel/git/
-#
 Aaron Durbin <[email protected]>
 Adam Oldham <[email protected]>
 Adam Radford <[email protected]>
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#4 lore raw

Re: [PATCH] shortlog: remove unused(?) "repo-abbrev" feature

In reply to Ævar Arnfjörð Bjarmason

Hi Ævar,

Quoted 15 lines · Ævar Arnfjörð Bjarmason
 {
        char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
(quoted diff) +0 -12
-       if (buffer[0] == '#') {
-               static const char abbrev[] = "# repo-abbrev:";
-               int abblen = sizeof(abbrev) - 1;
-               int len = strlen(buffer);
 
-               if (!repo_abbrev)
-                       return;
-
-               if (len && buffer[len - 1] == '\n')
-                       buffer[--len] = 0;
-               if (!strncmp(buffer, abbrev, abblen)) {
-                       char *cp;
-

Review

Quoted 10 lines
(quoted diff) +0 -8
-                       free(*repo_abbrev);
-
-                       for (cp = buffer + abblen; isspace(*cp); cp++)
-                               ; /* nothing */
-                       *repo_abbrev = xstrdup(cp);
-               }
-               return;
-       }
        if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
                parse_name_and_email(name2, &name2, &email2, 1);

I think this is a tiny bit too aggressive -- it stops recognizing and skipping comments. For example, this whitespace-damaged diff:

t/t4203-mailmap.sh +0 -0
index 586c3a86b1..4d461ad343 100755
@@ -373,6 +373,7 @@ test_expect_success 'Shortlog output (complex mapping)' '
        echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap &&
        echo "<[email protected]>

<[email protected]>" >> internal_mailmap/.mailmap &&
echo "Some Dude <[email protected]> nick1
<[email protected]>" >> internal_mailmap/.mailmap &&
+ echo "# Comment <[email protected]> nick1 <[email protected]>"

Quoted 1 line
Quoted 1 line

internal_mailmap/.mailmap &&

echo "Other Author <[email protected]> nick2
<[email protected]>" >> internal_mailmap/.mailmap &&
echo "Other Author <[email protected]>
<[email protected]>" >> internal_mailmap/.mailmap &&
echo "Santa Claus <[email protected]> <[email protected]>"

Quoted 1 line
Quoted 1 line

internal_mailmap/.mailmap &&

... 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

#5 lore raw

Re: [PATCH] shortlog: remove unused(?) "repo-abbrev" feature

In reply to Ævar Arnfjörð Bjarmason
Quoted 11 lines · Ævar Arnfjörð Bjarmason

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.

#6 lore raw

PATCH 1/22 mailmap doc: create a new "gitmailmap(5)" man page

In reply to Ævar Arnfjörð Bjarmason

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

---
 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%)
Documentation/Makefile +1 -0
index b980407059..81d1bf7a04 100644
@@ -21,6 +21,7 @@ MAN1_TXT += gitweb.txt
 MAN5_TXT += gitattributes.txt
 MAN5_TXT += githooks.txt
 MAN5_TXT += gitignore.txt
+MAN5_TXT += gitmailmap.txt
 MAN5_TXT += gitmodules.txt
 MAN5_TXT += gitrepository-layout.txt
 MAN5_TXT += gitweb.conf.txt
Documentation/git-blame.txt +1 -1
index 34b496d485..3bf5d5d8b4 100644
@@ -226,7 +226,7 @@ commit commentary), a blame viewer will not care.
 MAPPING AUTHORS
 ---------------
 
-include::mailmap.txt[]
+See linkgit:gitmailmap[5].
 
 
 SEE ALSO
Documentation/git-check-mailmap.txt +1 -1
index aa2055dbeb..45a5cfafd8 100644
@@ -39,7 +39,7 @@ printed; otherwise only ``$$<user@host>$$'' is printed.
 MAPPING AUTHORS
 ---------------
 
-include::mailmap.txt[]
+See linkgit:gitmailmap[5].
 
 
 GIT
Documentation/git-shortlog.txt +1 -5
index fd93cd41e9..c16cc3b608 100644
@@ -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
 ---
Documentation/gitmailmap.txt renamed from Documentation/mailmap.txt +33 -0
similarity index 88%
rename from Documentation/mailmap.txt
rename to Documentation/gitmailmap.txt
index 4a8c276529..8b07f9c5d7 100644
@@ -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 <[email protected]> <[email protected]>
 
 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
command-list.txt +1 -0
index 9379b02e5e..a289f09ed6 100644
@@ -204,6 +204,7 @@ gitfaq                                  guide
 gitglossary                             guide
 githooks                                guide
 gitignore                               guide
+gitmailmap                              guide
 gitmodules                              guide
 gitnamespaces                           guide
 gitremote-helpers                       guide
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#7 lore raw

Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page

Hi Ævar,

Le 2021-01-12 à 15:17, Ævar Arnfjörð Bjarmason a écrit :

Quoted 10 lines

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

I think that's a good idea.

Quoted 9 lines
---
  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 +

Nice to see that the comment I added in Documentation/Makefile about command-list.txt served its purpose :)

Quoted 3 lines
  6 files changed, 38 insertions(+), 7 deletions(-)

rename Documentation/{mailmap.txt => gitmailmap.txt} (88%)

-- 8< --

Quoted 8 lines
Documentation/gitmailmap.txt renamed from Documentation/mailmap.txt +0 -0
similarity index 88%
rename from Documentation/mailmap.txt
rename to Documentation/gitmailmap.txt
index 4a8c276529..8b07f9c5d7 100644

Documentation/gitmailmap.txt line 10

Quoted 10 lines
Documentation/gitmailmap.txt renamed from Documentation/mailmap.txt +10 -0
@@ -1,9 +1,28 @@
+gitmailmap(5)
+=============
+
+NAME
+----
+gitmailmap - Map author/committer names and/or E-Mail addresses
+
+SYNOPSIS
+--------
+$GIT_WORK_DIR/.mailmap

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/[email protected]/

#8 lore raw

Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page

Quoted 6 lines · Philippe Blain
Quoted 3 lines

+SYNOPSIS
+--------
+$GIT_WORK_DIR/.mailmap

This should be GIT_WORK_TREE, gitmodules(5) is wrong as GIT_WORK_DIR does not exists (my series at [1] fixes this).

Well spotted.

Can you make the suggestion into a follow-up patch to the series to be applied on top?

Thanks.

#9 lore raw

Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page

Hi Junio

Le 2021-01-14 à 14:58, Junio C Hamano a écrit :

Quoted 6 lines
Quoted 4 lines · Philippe Blain
Quoted 3 lines

+SYNOPSIS
+--------
+$GIT_WORK_DIR/.mailmap

Quoted 8 lines
Quoted 2 lines

This should be GIT_WORK_TREE, gitmodules(5) is wrong as GIT_WORK_DIR does not exists (my series at [1] fixes this).

Well spotted.

Can you make the suggestion into a follow-up patch to the series to be applied on top?

I just sent [1] as a fixup! commit (is that what you meant?) I was not sure...) I feel it is cleaner for that commit to use the correct variable name from the start, hence the fixup.

Philippe.

[1] https://lore.kernel.org/git/[email protected]/T/#m9e8e8f5458db71153c2363acf4bff959df7d0f4c

#10 lore raw

Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page

Quoted 2 lines · Philippe Blain

I was not sure...) I feel it is cleaner for that commit to use the correct variable name from the start, hence the fixup.

The topic is already in 'next', and that is why I asked follow-up patches on top from people. Otherwise I wouldn't have asked and instead just squashed these fixes in while the topic was in 'seen'.

Thanks.

#11 lore raw

Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page

Le 2021-01-14 à 22:18, Junio C Hamano a écrit :

Quoted 8 lines
Quoted 2 lines · Philippe Blain

I was not sure...) I feel it is cleaner for that commit to use the correct variable name from the start, hence the fixup.

The topic is already in 'next', and that is why I asked follow-up patches on top from people. Otherwise I wouldn't have asked and instead just squashed these fixes in while the topic was in 'seen'.

OK, thanks for clarifying. I did not check the status of the series, probably because I saw it was from just 2 days ago so I did not think it would already be in next. I just sent a v2 with a proper commit message [2].

I'm still not sure I have should have sent it as a reply to the commit it's fixing (as I did), or to the last commit of the series, or to the cover letter, or as a new thread to the list... what's the etiquette around this ? (I'm still new to the email workflow, especially around multi-author series...)

Philippe.

[2] https://lore.kernel.org/git/[email protected]/

#12 lore raw

Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page

Quoted 3 lines · Philippe Blain

I'm still not sure I have should have sent it as a reply to the commit it's fixing (as I did), or to the last commit of the series, or to the cover letter, or as a new thread to the list... what's the etiquette around this ?

I can deal with any of the above, but with the goal of keeping the list archive most useful for later readers, I would imagine that it would be best if such a follow-up fix were made against the specific step (if there is such a single step) that introduced an issue (in other words, where you would have squashed your fix into, if it were under your control to redo the series). If there is no such single step and the fix applies to the whole series in general, a response to its cover letter would also do, I would think.

Thanks.

#13 lore raw

PATCH 1/1 fixup! mailmap doc: create a new "gitmailmap(5)" man page

In reply to Ævar Arnfjörð Bjarmason
---
 Documentation/gitmailmap.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/gitmailmap.txt +1 -1
index 7f1089786d..052209b33b 100644
@@ -7,7 +7,7 @@ gitmailmap - Map author/committer names and/or E-Mail addresses
 
 SYNOPSIS
 --------
-$GIT_WORK_DIR/.mailmap
+$GIT_WORK_TREE/.mailmap
 
 
 DESCRIPTION

base-commit: 4e168333a8716d902aed10c74ae5e408e683f902

Signature · 1 line
2.29.2
#14 lore raw

PATCH v2 1/1 mailmap doc: use correct environment variable 'GIT_WORK_TREE'

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'.

---
 Documentation/gitmailmap.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/gitmailmap.txt +1 -1
index 7f1089786d..052209b33b 100644
@@ -7,7 +7,7 @@ gitmailmap - Map author/committer names and/or E-Mail addresses
 
 SYNOPSIS
 --------
-$GIT_WORK_DIR/.mailmap
+$GIT_WORK_TREE/.mailmap
 
 
 DESCRIPTION

base-commit: 4e168333a8716d902aed10c74ae5e408e683f902

Signature · 1 line
2.29.2
#15 lore raw

PATCH 2/22 mailmap doc: quote config variables `like.this`

In reply to Ævar Arnfjörð Bjarmason

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.

---
 Documentation/gitmailmap.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/gitmailmap.txt +2 -2
index 8b07f9c5d7..e75eadde63 100644
@@ -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.
 
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#16 lore raw

PATCH 3/22 check-mailmap doc: note config options

In reply to Ævar Arnfjörð Bjarmason

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.

---
 Documentation/git-check-mailmap.txt | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/git-check-mailmap.txt +7 -0
index 45a5cfafd8..02f4418323 100644
@@ -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
 ---------------
 
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#17 lore raw

PATCH 4/22 mailmap doc: start by mentioning the comment syntax

In reply to Ævar Arnfjörð Bjarmason

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.

---
 Documentation/gitmailmap.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/gitmailmap.txt +3 -2
index e75eadde63..4e4677018b 100644
@@ -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 <[email protected]>         <[email protected]>
 Santa Claus <[email protected]> <[email protected]>
 ------------
 
-Use hash '#' for comments that are either on their own line, or after
-the email address.
 
 
 SEE ALSO
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#18 lore raw

PATCH 5/22 mailmap tests: use our preferred whitespace syntax

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t4203-mailmap.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
t/t4203-mailmap.sh +8 -8
index 586c3a86b1..034a78aba1 100755
@@ -13,7 +13,7 @@ fuzz_blame () {
 }
 
 test_expect_success setup '
-	cat >contacts <<- EOF &&
+	cat >contacts <<-EOF &&
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	nick1 <[email protected]>
 	EOF
@@ -33,7 +33,7 @@ test_expect_success 'check-mailmap no arguments' '
 '
 
 test_expect_success 'check-mailmap arguments' '
-	cat >expect <<- EOF &&
+	cat >expect <<-EOF &&
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	nick1 <[email protected]>
 	EOF
@@ -44,7 +44,7 @@ test_expect_success 'check-mailmap arguments' '
 '
 
 test_expect_success 'check-mailmap --stdin' '
-	cat >expect <<- EOF &&
+	cat >expect <<-EOF &&
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	nick1 <[email protected]>
 	EOF
@@ -195,10 +195,10 @@ test_expect_success 'No mailmap files, but configured' '
 test_expect_success 'setup mailmap blob tests' '
 	git checkout -b map &&
 	test_when_finished "git checkout master" &&
-	cat >just-bugs <<- EOF &&
+	cat >just-bugs <<-\EOF &&
 	Blob Guy <[email protected]>
 	EOF
-	cat >both <<- EOF &&
+	cat >both <<-EOF &&
 	Blob Guy <$GIT_AUTHOR_EMAIL>
 	Blob Guy <[email protected]>
 	EOF
@@ -471,7 +471,7 @@ test_expect_success 'Log output with log.mailmap' '
 '
 
 test_expect_success 'log.mailmap=false disables mailmap' '
-	cat >expect <<- EOF &&
+	cat >expect <<-EOF &&
 	Author: CTO <[email protected]>
 	Author: claus <[email protected]>
 	Author: santa <[email protected]>
@@ -480,12 +480,12 @@ test_expect_success 'log.mailmap=false disables mailmap' '
 	Author: nick1 <[email protected]>
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
-	git -c log.mailmap=False log | grep Author > actual &&
+	git -c log.mailmap=False log | grep Author >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success '--no-use-mailmap disables mailmap' '
-	cat >expect <<- EOF &&
+	cat >expect <<-EOF &&
 	Author: CTO <[email protected]>
 	Author: claus <[email protected]>
 	Author: santa <[email protected]>
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#19 lore raw

PATCH 6/22 mailmap tests: modernize syntax & test idioms

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t4203-mailmap.sh | 473 ++++++++++++++++++++++++++-------------------
 1 file changed, 274 insertions(+), 199 deletions(-)
t/t4203-mailmap.sh +274 -199
index 034a78aba1..61d1b62317 100755
@@ -12,7 +12,7 @@ fuzz_blame () {
 	" "$@"
 }
 
-test_expect_success setup '
+test_expect_success 'setup commits and contacts file' '
 	cat >contacts <<-EOF &&
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	nick1 <[email protected]>
@@ -66,128 +66,164 @@ test_expect_success 'check-mailmap bogus contact' '
 	test_must_fail git check-mailmap bogus
 '
 
-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' '
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Repo Guy (1):
-      initial
+test_expect_success 'setup default .mailmap' '
+	cat >default.map <<-EOF
+	Repo Guy <$GIT_AUTHOR_EMAIL>
+	EOF
+'
+
+test_expect_success 'test default .mailmap' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-nick1 (1):
-      second
+	cat >expect <<-\EOF &&
+	Repo Guy (1):
+	      initial
 
-EOF
+	nick1 (1):
+	      second
 
-test_expect_success 'default .mailmap' '
-	echo "Repo Guy <$GIT_AUTHOR_EMAIL>" > .mailmap &&
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-# 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
-Internal Guy (1):
-      second
+test_expect_success 'mailmap.file set' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-Repo Guy (1):
-      initial
+	test_config mailmap.file internal.map &&
+	cat >internal.map <<-\EOF &&
+	Internal Guy <[email protected]>
+	EOF
 
-EOF
-test_expect_success 'mailmap.file set' '
-	mkdir -p internal_mailmap &&
-	echo "Internal Guy <[email protected]>" > internal_mailmap/.mailmap &&
-	git config mailmap.file internal_mailmap/.mailmap &&
+	cat >expect <<-\EOF &&
+	Internal Guy (1):
+	      second
+
+	Repo Guy (1):
+	      initial
+
+	EOF
 	git shortlog HEAD >actual &&
-	test_cmp expect actual
+	test_cmp expect actual &&
+
+	# 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" &&
+	git clone . sub-repo &&
+	(
+		cd sub-repo &&
+		cp ../.mailmap . &&
+		git config mailmap.file ../internal.map &&
+		git shortlog HEAD >actual &&
+		test_cmp ../expect actual
+	)
 '
 
-cat >expect <<\EOF
-External Guy (1):
-      initial
+test_expect_success 'mailmap.file override' '
+	test_config mailmap.file internal.map &&
+	cat >internal.map <<-EOF &&
+	Internal Guy <[email protected]>
+	External Guy <$GIT_AUTHOR_EMAIL>
+	EOF
 
-Internal Guy (1):
-      second
+	cat >expect <<-\EOF &&
+	External Guy (1):
+	      initial
 
-EOF
-test_expect_success 'mailmap.file override' '
-	echo "External Guy <$GIT_AUTHOR_EMAIL>" >> internal_mailmap/.mailmap &&
-	git config mailmap.file internal_mailmap/.mailmap &&
+	Internal Guy (1):
+	      second
+
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Repo Guy (1):
-      initial
+test_expect_success 'mailmap.file non-existent' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-nick1 (1):
-      second
+	cat >expect <<-\EOF &&
+	Repo Guy (1):
+	      initial
 
-EOF
+	nick1 (1):
+	      second
 
-test_expect_success 'mailmap.file non-existent' '
-	rm internal_mailmap/.mailmap &&
-	rmdir internal_mailmap &&
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Internal Guy (1):
-      second
+test_expect_success 'name entry after email entry' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-Repo Guy (1):
-      initial
+	test_config mailmap.file internal.map &&
+	cat >internal.map <<-\EOF &&
+	<[email protected]> <[email protected]>
+	Internal Guy <[email protected]>
+	EOF
 
-EOF
+	cat >expect <<-\EOF &&
+	Internal Guy (1):
+	      second
+
+	Repo Guy (1):
+	      initial
+
+	EOF
 
-test_expect_success 'name entry after email entry' '
-	mkdir -p internal_mailmap &&
-	echo "<[email protected]> <[email protected]>" >internal_mailmap/.mailmap &&
-	echo "Internal Guy <[email protected]>" >>internal_mailmap/.mailmap &&
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Internal Guy (1):
-      second
+test_expect_success 'name entry after email entry, case-insensitive' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
 
-Repo Guy (1):
-      initial
+	test_config mailmap.file internal.map &&
+	cat >internal.map <<-\EOF &&
+	<[email protected]> <[email protected]>
+	Internal Guy <[email protected]>
+	EOF
 
-EOF
+	cat >expect <<-\EOF &&
+	Internal Guy (1):
+	      second
+
+	Repo Guy (1):
+	      initial
+
+	EOF
 
-test_expect_success 'name entry after email entry, case-insensitive' '
-	mkdir -p internal_mailmap &&
-	echo "<[email protected]> <[email protected]>" >internal_mailmap/.mailmap &&
-	echo "Internal Guy <[email protected]>" >>internal_mailmap/.mailmap &&
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
 
-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 .mailmap internal_mailmap/.mailmap &&
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
@@ -205,11 +241,16 @@ test_expect_success 'setup mailmap blob tests' '
 	printf "Tricky Guy <$GIT_AUTHOR_EMAIL>" >no-newline &&
 	git add just-bugs both no-newline &&
 	git commit -m "my mailmaps" &&
-	echo "Repo Guy <$GIT_AUTHOR_EMAIL>" >.mailmap &&
-	echo "Internal Guy <$GIT_AUTHOR_EMAIL>" >internal.map
+
+	cat >internal.map <<-EOF
+	Internal Guy <$GIT_AUTHOR_EMAIL>
+	EOF
 '
 
 test_expect_success 'mailmap.blob set' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
+
 	cat >expect <<-\EOF &&
 	Blob Guy (1):
 	      second
@@ -223,6 +264,9 @@ test_expect_success 'mailmap.blob set' '
 '
 
 test_expect_success 'mailmap.blob overrides .mailmap' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
+
 	cat >expect <<-\EOF &&
 	Blob Guy (2):
 	      initial
@@ -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" &&
+	cp default.map .mailmap &&
+
 	cat >expect <<-\EOF &&
 	Repo Guy (1):
 	      initial
@@ -267,11 +314,15 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' '
 	(
 		cd non-bare &&
 		test_commit one .mailmap "Fake Name <$GIT_AUTHOR_EMAIL>" &&
-		echo "     1	Fake Name" >expect &&
+		cat >expect <<-\EOF &&
+		     1	Fake Name
+		EOF
 		git shortlog -ns HEAD >actual &&
 		test_cmp expect actual &&
 		rm .mailmap &&
-		echo "     1	$GIT_AUTHOR_NAME" >expect &&
+		cat >expect <<-EOF &&
+		     1	$GIT_AUTHOR_NAME
+		EOF
 		git shortlog -ns HEAD >actual &&
 		test_cmp expect actual
 	)
@@ -281,7 +332,9 @@ test_expect_success 'mailmap.blob defaults to HEAD:.mailmap in bare repo' '
 	git clone --bare non-bare bare &&
 	(
 		cd bare &&
-		echo "     1	Fake Name" >expect &&
+		cat >expect <<-\EOF &&
+		     1	Fake Name
+		EOF
 		git shortlog -ns HEAD >actual &&
 		test_cmp expect actual
 	)
@@ -300,50 +353,46 @@ test_expect_success 'mailmap.blob can handle blobs without trailing newline' '
 	test_cmp expect actual
 '
 
-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 <[email protected]>" >>expect &&
-	echo "A <$GIT_AUTHOR_EMAIL>" >.mailmap &&
 	test_when_finished "rm .mailmap" &&
+	cat >.mailmap <<-EOF &&
+	A <$GIT_AUTHOR_EMAIL>
+	EOF
+
+	cat >expect <<-EOF &&
+	     1	A <$GIT_AUTHOR_EMAIL>
+	     1	nick1 <[email protected]>
+	EOF
 	git shortlog -es HEAD >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'preserve canonical email case' '
-	echo "     1	$GIT_AUTHOR_NAME <[email protected]>" >expect &&
-	echo "     1	nick1 <[email protected]>" >>expect &&
-	echo "<[email protected]> <$GIT_AUTHOR_EMAIL>" >.mailmap &&
 	test_when_finished "rm .mailmap" &&
+	cat >.mailmap <<-EOF &&
+	<[email protected]> <$GIT_AUTHOR_EMAIL>
+	EOF
+
+	cat >expect <<-EOF &&
+	     1	$GIT_AUTHOR_NAME <[email protected]>
+	     1	nick1 <[email protected]>
+	EOF
 	git shortlog -es HEAD >actual &&
 	test_cmp expect actual
 '
 
-# Extended mailmap configurations should give us the following output for shortlog
-cat >expect << EOF
-$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
-      initial
-
-CTO <[email protected]> (1):
-      seventh
-
-Other Author <[email protected]> (2):
-      third
-      fourth
-
-Santa Claus <[email protected]> (2):
-      fifth
-      sixth
-
-Some Dude <[email protected]> (1):
-      second
-
-EOF
-
 test_expect_success 'Shortlog output (complex mapping)' '
+	test_config mailmap.file complex.map &&
+	cat >complex.map <<-EOF &&
+	Committed <$GIT_COMMITTER_EMAIL>
+	<[email protected]> <[email protected]>
+	Some Dude <[email protected]>         nick1 <[email protected]>
+	Other Author <[email protected]>   nick2 <[email protected]>
+	Other Author <[email protected]>         <[email protected]>
+	Santa Claus <[email protected]> <[email protected]>
+	Santa Claus <[email protected]> <[email protected]>
+	EOF
+
 	echo three >>one &&
 	git add one &&
 	test_tick &&
@@ -369,103 +418,119 @@ test_expect_success 'Shortlog output (complex mapping)' '
 	test_tick &&
 	git commit --author "CTO <[email protected]>" -m seventh &&
 
-	mkdir -p internal_mailmap &&
-	echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap &&
-	echo "<[email protected]>                       <[email protected]>" >> internal_mailmap/.mailmap &&
-	echo "Some Dude <[email protected]>         nick1 <[email protected]>" >> internal_mailmap/.mailmap &&
-	echo "Other Author <[email protected]>   nick2 <[email protected]>" >> internal_mailmap/.mailmap &&
-	echo "Other Author <[email protected]>         <[email protected]>" >> internal_mailmap/.mailmap &&
-	echo "Santa Claus <[email protected]> <[email protected]>" >> internal_mailmap/.mailmap &&
-	echo "Santa Claus <[email protected]> <[email protected]>" >> internal_mailmap/.mailmap &&
+	cat >expect <<-EOF &&
+	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
+	      initial
+
+	CTO <[email protected]> (1):
+	      seventh
+
+	Other Author <[email protected]> (2):
+	      third
+	      fourth
+
+	Santa Claus <[email protected]> (2):
+	      fifth
+	      sixth
+
+	Some Dude <[email protected]> (1):
+	      second
+
+	EOF
 
 	git shortlog -e HEAD >actual &&
 	test_cmp expect actual
 
 '
 
-# git log with --pretty format which uses the name and email mailmap placemarkers
-cat >expect << EOF
-Author CTO <[email protected]> maps to CTO <[email protected]>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+test_expect_success 'Log output (complex mapping)' '
+	test_config mailmap.file complex.map &&
 
-Author claus <[email protected]> maps to Santa Claus <[email protected]>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	cat >expect <<-EOF &&
+	Author CTO <[email protected]> maps to CTO <[email protected]>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author santa <[email protected]> maps to Santa Claus <[email protected]>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author claus <[email protected]> maps to Santa Claus <[email protected]>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick2 <[email protected]> maps to Other Author <[email protected]>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author santa <[email protected]> maps to Santa Claus <[email protected]>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick2 <[email protected]> maps to Other Author <[email protected]>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author nick2 <[email protected]> maps to Other Author <[email protected]>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick1 <[email protected]> maps to Some Dude <[email protected]>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author nick2 <[email protected]> maps to Other Author <[email protected]>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
-EOF
+	Author nick1 <[email protected]> maps to Some Dude <[email protected]>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+
+	Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	EOF
 
-test_expect_success 'Log output (complex mapping)' '
 	git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
 	test_cmp expect actual
 '
 
-cat >expect << EOF
-Author email [email protected] has local-part cto
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+test_expect_success 'Log output (local-part email address)' '
+	cat >expect <<-EOF &&
+	Author email [email protected] has local-part cto
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email [email protected] has local-part me
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email [email protected] has local-part me
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email [email protected] has local-part me
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email [email protected] has local-part me
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email [email protected] has local-part nick2
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email [email protected] has local-part nick2
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email [email protected] has local-part bugs
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email [email protected] has local-part bugs
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email [email protected] has local-part bugs
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email [email protected] has local-part bugs
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email [email protected] has local-part author
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
-EOF
+	Author email [email protected] has local-part author
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	EOF
 
-test_expect_success 'Log output (local-part email address)' '
 	git log --pretty=format:"Author email %ae has local-part %al%nCommitter email %ce has local-part %cl%n" >actual &&
 	test_cmp expect actual
 '
 
-cat >expect << EOF
-Author: CTO <[email protected]>
-Author: Santa Claus <[email protected]>
-Author: Santa Claus <[email protected]>
-Author: Other Author <[email protected]>
-Author: Other Author <[email protected]>
-Author: Some Dude <[email protected]>
-Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
-EOF
-
 test_expect_success 'Log output with --use-mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-EOF &&
+	Author: CTO <[email protected]>
+	Author: Santa Claus <[email protected]>
+	Author: Santa Claus <[email protected]>
+	Author: Other Author <[email protected]>
+	Author: Other Author <[email protected]>
+	Author: Some Dude <[email protected]>
+	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+	EOF
+
 	git log --use-mailmap | grep Author >actual &&
 	test_cmp expect actual
 '
 
-cat >expect << EOF
-Author: CTO <[email protected]>
-Author: Santa Claus <[email protected]>
-Author: Santa Claus <[email protected]>
-Author: Other Author <[email protected]>
-Author: Other Author <[email protected]>
-Author: Some Dude <[email protected]>
-Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
-EOF
-
 test_expect_success 'Log output with log.mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-EOF &&
+	Author: CTO <[email protected]>
+	Author: Santa Claus <[email protected]>
+	Author: Santa Claus <[email protected]>
+	Author: Other Author <[email protected]>
+	Author: Other Author <[email protected]>
+	Author: Some Dude <[email protected]>
+	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+	EOF
+
 	git -c log.mailmap=True log | grep Author >actual &&
 	test_cmp expect actual
 '
@@ -480,7 +545,7 @@ test_expect_success 'log.mailmap=false disables mailmap' '
 	Author: nick1 <[email protected]>
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
-	git -c log.mailmap=False log | grep Author >actual &&
+	git -c log.mailmap=false log | grep Author >actual &&
 	test_cmp expect actual
 '
 
@@ -498,56 +563,66 @@ test_expect_success '--no-use-mailmap disables mailmap' '
 	test_cmp expect actual
 '
 
-cat >expect <<\EOF
-Author: Santa Claus <[email protected]>
-Author: Santa Claus <[email protected]>
-EOF
-
 test_expect_success 'Grep author with --use-mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Author: Santa Claus <[email protected]>
+	Author: Santa Claus <[email protected]>
+	EOF
 	git log --use-mailmap --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
-cat >expect <<\EOF
-Author: Santa Claus <[email protected]>
-Author: Santa Claus <[email protected]>
-EOF
 
 test_expect_success 'Grep author with log.mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Author: Santa Claus <[email protected]>
+	Author: Santa Claus <[email protected]>
+	EOF
+
 	git -c log.mailmap=True log --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'log.mailmap is true by default these days' '
+	test_config mailmap.file complex.map &&
 	git log --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'Only grep replaced author with --use-mailmap' '
+	test_config mailmap.file complex.map &&
 	git log --use-mailmap --author "<[email protected]>" >actual &&
 	test_must_be_empty actual
 '
 
-# git blame
-cat >expect <<EOF
-^OBJI ($GIT_AUTHOR_NAME     DATE 1) one
-OBJID (Some Dude    DATE 2) two
-OBJID (Other Author DATE 3) three
-OBJID (Other Author DATE 4) four
-OBJID (Santa Claus  DATE 5) five
-OBJID (Santa Claus  DATE 6) six
-OBJID (CTO          DATE 7) seven
-EOF
 test_expect_success 'Blame output (complex mapping)' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-EOF &&
+	^OBJI ($GIT_AUTHOR_NAME     DATE 1) one
+	OBJID (Some Dude    DATE 2) two
+	OBJID (Other Author DATE 3) three
+	OBJID (Other Author DATE 4) four
+	OBJID (Santa Claus  DATE 5) five
+	OBJID (Santa Claus  DATE 6) six
+	OBJID (CTO          DATE 7) seven
+	EOF
+
 	git blame one >actual &&
 	fuzz_blame actual >actual.fuzz &&
 	test_cmp expect actual.fuzz
 '
 
-cat >expect <<\EOF
-Some Dude <[email protected]>
-EOF
-
 test_expect_success 'commit --author honors mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Some Dude <[email protected]>
+	EOF
+
 	test_must_fail git commit --author "nick" --allow-empty -meight &&
 	git commit --author "Some Dude" --allow-empty -meight &&
 	git show --pretty=format:"%an <%ae>%n" >actual &&
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#20 lore raw

Re: [PATCH 06/22] mailmap tests: modernize syntax & test idioms

Hi Ævar,

t/t4203-mailmap.sh test_expect_success 'log.mailmap=false disables mailmap' ' · line 548

Quoted 6 lines · Ævar Arnfjörð Bjarmason
t/t4203-mailmap.sh +1 -1
@@ -480,7 +545,7 @@ test_expect_success 'log.mailmap=false disables mailmap' '
 	Author: nick1 <[email protected]>
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
-	git -c log.mailmap=False log | grep Author >actual &&
+	git -c log.mailmap=false log | grep Author >actual &&

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

Quoted 2 lines
(quoted diff) +0 -0
 	test_cmp expect actual
 '
#21 lore raw

Re: [PATCH 06/22] mailmap tests: modernize syntax & test idioms

Quoted 13 lines · Denton Liu

t/t4203-mailmap.sh test_expect_success 'log.mailmap=false disables mailmap' ' · line 548

Quoted 6 lines · Ævar Arnfjörð Bjarmason
t/t4203-mailmap.sh +1 -1
@@ -480,7 +545,7 @@ test_expect_success 'log.mailmap=false disables mailmap' '
 	Author: nick1 <[email protected]>
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
-	git -c log.mailmap=False log | grep Author >actual &&
+	git -c log.mailmap=false log | grep Author >actual &&

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.

Quoted 5 lines

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.

Yeah, I agree with your assessment that it does make sense to make sure this "log" does not crash silently.

I find it unlikely for "log" to crash while giving an expected Author line to its output stream, though.

Can you make your suggestion into a follow-up patch to be applied on top of the series?

Thanks.

#22 lore raw

PATCH 7/22 mailmap tests: improve --stdin tests

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t4203-mailmap.sh | 40 ++++++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 8 deletions(-)
t/t4203-mailmap.sh +32 -8
index 61d1b62317..dbd365681e 100755
@@ -13,11 +13,6 @@ fuzz_blame () {
 }
 
 test_expect_success 'setup commits and contacts file' '
-	cat >contacts <<-EOF &&
-	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
-	nick1 <[email protected]>
-	EOF
-
 	echo one >one &&
 	git add one &&
 	test_tick &&
@@ -48,24 +43,53 @@ test_expect_success 'check-mailmap --stdin' '
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	nick1 <[email protected]>
 	EOF
-	git check-mailmap --stdin <contacts >actual &&
+	git check-mailmap --stdin <expect >actual &&
 	test_cmp expect actual
 '
 
-test_expect_success 'check-mailmap --stdin arguments' '
+test_expect_success 'check-mailmap --stdin arguments: no mapping' '
+	test_when_finished "rm contacts" &&
+	cat >contacts <<-EOF &&
+	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+	nick1 <[email protected]>
+	EOF
 	cat >expect <<-\EOF &&
 	Internal Guy <[email protected]>
 	EOF
-	cat <contacts >>expect &&
+	cat contacts >>expect &&
+
 	git check-mailmap --stdin "Internal Guy <[email protected]>" \
 		<contacts >actual &&
 	test_cmp expect actual
 '
 
+test_expect_success 'check-mailmap --stdin arguments: mapping' '
+	test_when_finished "rm .mailmap" &&
+	cat >.mailmap <<-EOF &&
+	New Name <$GIT_AUTHOR_EMAIL>
+	EOF
+	cat >stdin <<-EOF &&
+	Old Name <$GIT_AUTHOR_EMAIL>
+	EOF
+
+	cp .mailmap expect &&
+	git check-mailmap --stdin <stdin >actual &&
+	test_cmp expect actual &&
+
+	cat .mailmap >>expect &&
+	git check-mailmap --stdin "Another Old Name <$GIT_AUTHOR_EMAIL>" \
+		<stdin >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'check-mailmap bogus contact' '
 	test_must_fail git check-mailmap bogus
 '
 
+test_expect_success 'check-mailmap bogus contact --stdin' '
+	test_must_fail git check-mailmap --stdin bogus </dev/null
+'
+
 test_expect_success 'No mailmap' '
 	cat >expect <<-EOF &&
 	$GIT_AUTHOR_NAME (1):
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#23 lore raw

PATCH 8/22 mailmap tests: remove redundant entry in test

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t4203-mailmap.sh | 1 -
 1 file changed, 1 deletion(-)
t/t4203-mailmap.sh +0 -1
index dbd365681e..03a98d9635 100755
@@ -414,7 +414,6 @@ test_expect_success 'Shortlog output (complex mapping)' '
 	Other Author <[email protected]>   nick2 <[email protected]>
 	Other Author <[email protected]>         <[email protected]>
 	Santa Claus <[email protected]> <[email protected]>
-	Santa Claus <[email protected]> <[email protected]>
 	EOF
 
 	echo three >>one &&
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#24 lore raw

PATCH 9/22 mailmap tests: add a test for "not a blob" error

In reply to Ævar Arnfjörð Bjarmason

Add a test for one of the error conditions added in 938a60d64f (mailmap: clean up read_mailmap error handling, 2012-12-12).

---
 t/t4203-mailmap.sh | 9 +++++++++
 1 file changed, 9 insertions(+)
t/t4203-mailmap.sh +9 -0
index 03a98d9635..78d56e0566 100755
@@ -333,6 +333,15 @@ test_expect_success 'mailmap.blob can be missing' '
 	test_cmp expect actual
 '
 
+test_expect_success 'mailmap.blob might be the wrong type' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
+
+	git -c mailmap.blob=HEAD: shortlog HEAD >actual 2>err &&
+	test_i18ngrep "mailmap is not a blob" err &&
+	test_cmp expect actual
+'
+
 test_expect_success 'mailmap.blob defaults to off in non-bare repo' '
 	git init non-bare &&
 	(
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#25 lore raw

Re: [PATCH 09/22] mailmap tests: add a test for "not a blob" error

Quoted 8 lines · Ævar Arnfjörð Bjarmason

Add a test for one of the error conditions added in 938a60d64f (mailmap: clean up read_mailmap error handling, 2012-12-12).

---
 t/t4203-mailmap.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

Nice to see a patch that tries to be careful, like this one.

Quoted 20 lines
t/t4203-mailmap.sh +9 -0
index 03a98d9635..78d56e0566 100755
@@ -333,6 +333,15 @@ test_expect_success 'mailmap.blob can be missing' '
 	test_cmp expect actual
 '
 
+test_expect_success 'mailmap.blob might be the wrong type' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
+
+	git -c mailmap.blob=HEAD: shortlog HEAD >actual 2>err &&
+	test_i18ngrep "mailmap is not a blob" err &&
+	test_cmp expect actual
+'
+
 test_expect_success 'mailmap.blob defaults to off in non-bare repo' '
 	git init non-bare &&
 	(
#26 lore raw

PATCH 10/22 mailmap tests: get rid of overly complex blame fuzzing

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t4203-mailmap.sh | 50 +++++++++++++++++++++++++++-------------------
 1 file changed, 30 insertions(+), 20 deletions(-)
t/t4203-mailmap.sh +30 -20
index 78d56e0566..a42b454756 100755
@@ -4,14 +4,6 @@ test_description='.mailmap configurations'
 
 . ./test-lib.sh
 
-fuzz_blame () {
-	sed "
-		s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g
-		s/$_x05[0-9a-f][0-9a-f]/OBJI/g
-		s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
-	" "$@"
-}
-
 test_expect_success 'setup commits and contacts file' '
 	echo one >one &&
 	git add one &&
@@ -630,24 +622,42 @@ test_expect_success 'Only grep replaced author with --use-mailmap' '
 	test_must_be_empty actual
 '
 
-test_expect_success 'Blame output (complex mapping)' '
+test_expect_success 'Blame --porcelain output (complex mapping)' '
 	test_config mailmap.file complex.map &&
 
 	cat >expect <<-EOF &&
-	^OBJI ($GIT_AUTHOR_NAME     DATE 1) one
-	OBJID (Some Dude    DATE 2) two
-	OBJID (Other Author DATE 3) three
-	OBJID (Other Author DATE 4) four
-	OBJID (Santa Claus  DATE 5) five
-	OBJID (Santa Claus  DATE 6) six
-	OBJID (CTO          DATE 7) seven
-	EOF
-
-	git blame one >actual &&
-	fuzz_blame actual >actual.fuzz &&
+	1 1 1
+	A U Thor
+	2 2 1
+	Some Dude
+	3 3 1
+	Other Author
+	4 4 1
+	Other Author
+	5 5 1
+	Santa Claus
+	6 6 1
+	Santa Claus
+	7 7 1
+	CTO
+	EOF
+
+	git blame --porcelain one >actual.blame &&
+	grep -E \
+		-e "[0-9]+ [0-9]+ [0-9]+$" \
+		-e "^author .*$" \
+		actual.blame >actual.grep &&
+	cut -d " " -f2-4 <actual.grep >actual.fuzz &&
 	test_cmp expect actual.fuzz
 '
 
+test_expect_success 'Blame output (complex mapping)' '
+	git -c mailmap.file=complex.map blame one >a &&
+	git blame one >b &&
+	test_file_not_empty a &&
+	! cmp a b
+'
+
 test_expect_success 'commit --author honors mailmap' '
 	test_config mailmap.file complex.map &&
 
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#27 lore raw

Re: [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing

t/t4203-mailmap.sh test_expect_success 'Only grep replaced author with --use-mailmap' ' · line 650

Quoted 12 lines · Ævar Arnfjörð Bjarmason
t/t4203-mailmap.sh +12 -0
+	6 6 1
+	Santa Claus
+	7 7 1
+	CTO
+	EOF
+
+	git blame --porcelain one >actual.blame &&
+	grep -E \
+		-e "[0-9]+ [0-9]+ [0-9]+$" \
+		-e "^author .*$" \
+		actual.blame >actual.grep &&
+	cut -d " " -f2-4 <actual.grep >actual.fuzz &&

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.

#28 lore raw

Re: [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing

Quoted 17 lines · Junio C Hamano

Review

Quoted 12 lines · Ævar Arnfjörð Bjarmason
(quoted diff) +12 -0
+	6 6 1
+	Santa Claus
+	7 7 1
+	CTO
+	EOF
+
+	git blame --porcelain one >actual.blame &&
+	grep -E \
+		-e "[0-9]+ [0-9]+ [0-9]+$" \
+		-e "^author .*$" \
+		actual.blame >actual.grep &&
+	cut -d " " -f2-4 <actual.grep >actual.fuzz &&

An approach along the lines of ...

Quoted 6 lines
	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.

Trying to lead by example..., here is the suggestion in a follow-up patch form that can be applied on top of the series.

----- >8 ----- ----- >8 ----- ----- >8 ----- ----- >8 ----- ----- >8 -----
Subject: [PATCH] t4203: make blame output massaging more robust

In the "git blame --porcelain" output, lines that ends with three integers may not be the line that shows a commit object with line numbers and block length (the contents from the blamed file or the summary field can have a line that happens to match). Also, the names of the author may have more than three SP separated tokens ("git blame -L242,+1 cf6de18aabf7 Documentation/SubmittingPatches" gives an example). The existing "grep -E | cut" pipeline is a bit too loose on these two points.

While they can be assumed on the test data, it is not so hard to use the right pattern from the documented format, so let's do so.

---
 t/t4203-mailmap.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
t/t4203-mailmap.sh +5 -5
index 89cb300f28..d4a6e73736 100755
@@ -739,11 +739,11 @@ test_expect_success 'Blame --porcelain output (complex mapping)' '
 	EOF
 
 	git blame --porcelain one >actual.blame &&
-	grep -E \
-		-e "[0-9]+ [0-9]+ [0-9]+$" \
-		-e "^author .*$" \
-		actual.blame >actual.grep &&
-	cut -d " " -f2-4 <actual.grep >actual.fuzz &&
+
+	NUM="[0-9][0-9]*" &&
+	sed -n <actual.blame >actual.fuzz \
+		-e "s/^author //p" \
+		-e "s/^$OID_REGEX \\($NUM $NUM $NUM\\)$/\\1/p"  &&
 	test_cmp expect actual.fuzz
 '
 
#29 lore raw

PATCH 11/22 mailmap: test for silent exiting on missing file/blob

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t4203-mailmap.sh | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
t/t4203-mailmap.sh +20 -1
index a42b454756..2b342d7f7c 100755
@@ -309,6 +309,24 @@ test_expect_success 'mailmap.file overrides mailmap.blob' '
 	test_cmp expect actual
 '
 
+test_expect_success 'mailmap.file can be missing' '
+	test_when_finished "rm .mailmap" &&
+	cp default.map .mailmap &&
+
+	test_config mailmap.file nonexistent &&
+	cat >expect <<-\EOF &&
+	Repo Guy (1):
+	      initial
+
+	nick1 (1):
+	      second
+
+	EOF
+	git shortlog HEAD >actual 2>err &&
+	test_must_be_empty err &&
+	test_cmp expect actual
+'
+
 test_expect_success 'mailmap.blob can be missing' '
 	test_when_finished "rm .mailmap" &&
 	cp default.map .mailmap &&
@@ -321,7 +339,8 @@ test_expect_success 'mailmap.blob can be missing' '
 	      second
 
 	EOF
-	git -c mailmap.blob=map:nonexistent shortlog HEAD >actual &&
+	git -c mailmap.blob=map:nonexistent shortlog HEAD >actual 2>err &&
+	test_must_be_empty err &&
 	test_cmp expect actual
 '
 
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#30 lore raw

PATCH 12/22 test-lib functions: expand "test_commit" comment template

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/test-lib-functions.sh | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
t/test-lib-functions.sh +3 -5
index 999982fe4a..396e039d2a 100644
@@ -178,16 +178,14 @@ debug () {
 	GIT_DEBUGGER="${GIT_DEBUGGER}" "$@" <&6 >&5 2>&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= &&
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#31 lore raw

PATCH 13/22 test-lib functions: document arguments to test_commit

In reply to Ævar Arnfjörð Bjarmason

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)

---
 t/test-lib-functions.sh | 4 ++++
 1 file changed, 4 insertions(+)
t/test-lib-functions.sh +4 -0
index 396e039d2a..194b601bc0 100644
@@ -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.
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#32 lore raw

PATCH 14/22 test-lib functions: add --author support to test_commit

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t7509-commit-authorship.sh |  7 ++-----
 t/test-lib-functions.sh      | 11 ++++++++++-
 2 files changed, 12 insertions(+), 6 deletions(-)
t/t7509-commit-authorship.sh +2 -5
index 500ab2fe72..ee6c47416e 100755
@@ -18,11 +18,8 @@ message_body () {
 }
 
 test_expect_success '-C option copies authorship and message' '
-	echo "Initial" >foo &&
-	git add foo &&
-	test_tick &&
-	git commit -m "Initial Commit" --author Frigate\ \<[email protected]\> &&
-	git tag Initial &&
+	test_commit --author Frigate\ \<[email protected]\> \
+		"Initial Commit" foo Initial Initial &&
 	echo "Test 1" >>foo &&
 	test_tick &&
 	git commit -a -C Initial &&
t/test-lib-functions.sh +10 -1
index 194b601bc0..529f6264fe 100644
@@ -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.
@@ -193,6 +195,7 @@ debug () {
 
 test_commit () {
 	notick= &&
+	author= &&
 	signoff= &&
 	indir= &&
 	while test $# != 0
@@ -201,6 +204,10 @@ test_commit () {
 		--notick)
 			notick=yes
 			;;
+		--author)
+			author="$2"
+			shift
+			;;
 		--signoff)
 			signoff="$1"
 			;;
@@ -222,7 +229,9 @@ test_commit () {
 	then
 		test_tick
 	fi &&
-	git ${indir:+ -C "$indir"} commit $signoff -m "$1" &&
+	git ${indir:+ -C "$indir"} commit \
+	    ${author:+ --author "$author"} \
+	    $signoff -m "$1" &&
 	git ${indir:+ -C "$indir"} tag "${4:-$1}"
 }
 
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#33 lore raw

Re: [PATCH 14/22] test-lib functions: add --author support to test_commit

Quoted 6 lines · Ævar Arnfjörð Bjarmason

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.

Makes sense.

t/t7509-commit-authorship.sh message_body () { · line 22

Quoted 4 lines
t/t7509-commit-authorship.sh +2 -2
-	git commit -m "Initial Commit" --author Frigate\ \<[email protected]\> &&
-	git tag Initial &&
+	test_commit --author Frigate\ \<[email protected]\> \
+		"Initial Commit" foo Initial Initial &&

Why not fix the value of the author while at it to be more readable? E.g. --author "Frigate <[email protected]>"

#34 lore raw

Re: [PATCH 14/22] test-lib functions: add --author support to test_commit

In reply to Ævar Arnfjörð Bjarmason

Hi Ævar,

t/test-lib-functions.sh debug () { · line 188

Quoted 9 lines · Ævar Arnfjörð Bjarmason
t/test-lib-functions.sh +1 -0
index 194b601bc0..529f6264fe 100644
@@ -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 13 lines
t/test-lib-functions.sh +2 -0
+#	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.
@@ -193,6 +195,7 @@ debug () {
 
 test_commit () {
 	notick= &&
+	author= &&
 	signoff= &&
 	indir= &&
 	while test $# != 0

t/test-lib-functions.sh test_commit () { · line 208

Quoted 5 lines
t/test-lib-functions.sh +2 -0
@@ -201,6 +204,10 @@ test_commit () {
 		--notick)
 			notick=yes
 			;;
+		--author)
+			author="$2"

but over here, it's only parsed if they're presented as two separate tokens. We should correct the usage text accordingly.

Thanks,
Denton

Quoted 5 lines
t/test-lib-functions.sh +2 -0
+			shift
+			;;
 		--signoff)
 			signoff="$1"
 			;;
#35 lore raw

PATCH 15/22 test-lib functions: add an --append option to test_commit

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t4203-mailmap.sh      | 39 +++++++--------------------------------
 t/test-lib-functions.sh | 14 +++++++++++++-
 2 files changed, 20 insertions(+), 33 deletions(-)
t/t4203-mailmap.sh +7 -32
index 2b342d7f7c..5d92880a5a 100755
@@ -5,14 +5,8 @@ test_description='.mailmap configurations'
 . ./test-lib.sh
 
 test_expect_success 'setup commits and contacts file' '
-	echo one >one &&
-	git add one &&
-	test_tick &&
-	git commit -m initial &&
-	echo two >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "nick1 <[email protected]>" -m second
+	test_commit initial one one &&
+	test_commit --author "nick1 <[email protected]>" --append second one two
 '
 
 test_expect_success 'check-mailmap no arguments' '
@@ -436,30 +430,11 @@ test_expect_success 'Shortlog output (complex mapping)' '
 	Santa Claus <[email protected]> <[email protected]>
 	EOF
 
-	echo three >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "nick2 <[email protected]>" -m third &&
-
-	echo four >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "nick2 <[email protected]>" -m fourth &&
-
-	echo five >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "santa <[email protected]>" -m fifth &&
-
-	echo six >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "claus <[email protected]>" -m sixth &&
-
-	echo seven >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "CTO <[email protected]>" -m seventh &&
+	test_commit --author "nick2 <[email protected]>" --append third one three &&
+	test_commit --author "nick2 <[email protected]>" --append fourth one four &&
+	test_commit --author "santa <[email protected]>" --append fifth one five &&
+	test_commit --author "claus <[email protected]>" --append sixth one six &&
+	test_commit --author "CTO <[email protected]>" --append seventh one seven &&
 
 	cat >expect <<-EOF &&
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
t/test-lib-functions.sh +13 -1
index 529f6264fe..b0a5d74dc7 100644
@@ -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>
@@ -195,6 +198,7 @@ debug () {
 
 test_commit () {
 	notick= &&
+	append= &&
 	author= &&
 	signoff= &&
 	indir= &&
@@ -204,6 +208,9 @@ test_commit () {
 		--notick)
 			notick=yes
 			;;
+		--append)
+			append=yes
+			;;
 		--author)
 			author="$2"
 			shift
@@ -223,7 +230,12 @@ test_commit () {
 	done &&
 	indir=${indir:+"$indir"/} &&
 	file=${2:-"$1.t"} &&
-	echo "${3-$1}" > "$indir$file" &&
+	if test -n "$append"
+	then
+		echo "${3-$1}" >>"$indir$file"
+	else
+		echo "${3-$1}" >"$indir$file"
+	fi &&
 	git ${indir:+ -C "$indir"} add "$file" &&
 	if test -z "$notick"
 	then
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#36 lore raw

PATCH 16/22 tests: refactor a few tests to use "test_commit --append"

In reply to Ævar Arnfjörð Bjarmason

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.

---
 t/t1412-reflog-loop.sh   |  7 ++-----
 t/t2012-checkout-last.sh | 12 +++---------
 t/t7810-grep.sh          | 18 +++---------------
 3 files changed, 8 insertions(+), 29 deletions(-)
t/t1412-reflog-loop.sh +2 -5
index 3acd895afb..977603f7f1 100755
@@ -4,11 +4,8 @@ test_description='reflog walk shows repeated commits again'
 . ./test-lib.sh
 
 test_expect_success 'setup commits' '
-	test_tick &&
-	echo content >file && git add file && git commit -m one &&
-	git tag one &&
-	echo content >>file && git add file && git commit -m two &&
-	git tag two
+	test_commit one file content &&
+	test_commit --append two file content
 '
 
 test_expect_success 'setup reflog with alternating commits' '
t/t2012-checkout-last.sh +3 -9
index e7ba8c505f..c95aa3e78f 100755
@@ -5,13 +5,9 @@ test_description='checkout can switch to last branch and merge base'
 . ./test-lib.sh
 
 test_expect_success 'setup' '
-	echo hello >world &&
-	git add world &&
-	git commit -m initial &&
+	test_commit initial world hello &&
 	git branch other &&
-	echo "hello again" >>world &&
-	git add world &&
-	git commit -m second
+	test_commit --append second world "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' '
 	git checkout -b another other &&
-	echo "hello again" >>world &&
-	git add world &&
-	git commit -m third
+	test_commit --append third world "hello again"
 '
 
 test_expect_success 'another...master' '
t/t7810-grep.sh +3 -15
index 991d5bd9c0..312e0f8cb4 100755
@@ -687,21 +687,9 @@ test_expect_success 'grep -C1 hunk mark between files' '
 '
 
 test_expect_success 'log grep setup' '
-	echo a >>file &&
-	test_tick &&
-	GIT_AUTHOR_NAME="With * Asterisk" \
-	GIT_AUTHOR_EMAIL="[email protected]" \
-	git commit -a -m "second" &&
-
-	echo a >>file &&
-	test_tick &&
-	git commit -a -m "third" &&
-
-	echo a >>file &&
-	test_tick &&
-	GIT_AUTHOR_NAME="Night Fall" \
-	GIT_AUTHOR_EMAIL="[email protected]" \
-	git commit -a -m "fourth"
+	test_commit --append --author "With * Asterisk <[email protected]>" second file a &&
+	test_commit --append third file a &&
+	test_commit --append --author "Night Fall <[email protected]>" fourth file a
 '
 
 test_expect_success 'log grep (1)' '
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#37 lore raw

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

In reply to Ævar Arnfjörð Bjarmason

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.

---
 Documentation/gitmailmap.txt | 49 ++++++++++++--------
 t/t4203-mailmap.sh           | 88 ++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+), 20 deletions(-)
Documentation/gitmailmap.txt +29 -20
index 4e4677018b..55dfebd1b1 100644
@@ -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 <[email protected]>
+Jane Doe <[email protected]>
+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 <[email protected]>
+Jane Doe <[email protected]> <jane@laptop.(none)>
+Jane Doe <[email protected]> <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 <[email protected]>
-nick2 <[email protected]>
-nick2 <[email protected]>
-santa <[email protected]>
-claus <[email protected]>
-CTO <[email protected]>
+Joe <[email protected]>
+Jane <[email protected]>
 ------------
 
-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:
+
 ------------
-<[email protected]>                       <[email protected]>
-Some Dude <[email protected]>         nick1 <[email protected]>
-Other Author <[email protected]>   nick2 <[email protected]>
-Other Author <[email protected]>         <[email protected]>
-Santa Claus <[email protected]> <[email protected]>
+Joe R. Developer <[email protected]>
+Jane Doe <[email protected]> <jane@laptop.(none)>
+Jane Doe <[email protected]> <jane@desktop.(none)>
+Joe R. Developer <[email protected]> Joe <[email protected]>
+Jane Doe <[email protected]> Jane <[email protected]>
 ------------
 
 
t/t4203-mailmap.sh +88 -0

94 lines not on this page · raw message

Signature · 1 line
2.29.2.222.g5d2a92d10f8
#38 lore raw

PATCH 18/22 mailmap tests: add a test for comment syntax

In reply to Ævar Arnfjörð Bjarmason

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/

---
 t/t4203-mailmap.sh | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
t/t4203-mailmap.sh +33 -0
index 96ba5367c6..10e672e006 100755
@@ -753,4 +753,37 @@ test_expect_success 'commit --author honors mailmap' '
 	test_cmp expect actual
 '
 
+test_expect_success 'comment syntax: setup' '
+	test_create_repo comm &&
+	test_commit -C comm --author "A <[email protected]>" A &&
+	test_commit -C comm --author "B <[email protected]>" B &&
+	test_commit -C comm --author "C <#@example.com>" C &&
+	test_commit -C comm --author "D <d@e#ample.com>" D &&
+
+	test_config -C comm mailmap.file ../doc.map &&
+	cat >>doc.map <<-\EOF &&
+	# Ah <[email protected]>
+
+	; Bee <[email protected]>
+	Cee <[email protected]> <#@example.com>
+	Dee <[email protected]> <d@e#ample.com>
+	EOF
+
+	cat >expect <<-\EOF &&
+	Author A <[email protected]> maps to A <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author B <[email protected]> maps to ; Bee <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author C <#@example.com> maps to Cee <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author D <d@e#ample.com> maps to Dee <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+	EOF
+	git -C comm 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_done
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#39 lore raw

PATCH 19/22 mailmap tests: add tests for whitespace syntax

In reply to Ævar Arnfjörð Bjarmason

Add tests for mailmap's handling of whitespace, i.e. how it trims space within "<>" and around author names.

---
 t/t4203-mailmap.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
t/t4203-mailmap.sh +52 -0
index 10e672e006..4f61655c04 100755
@@ -786,4 +786,56 @@ test_expect_success 'comment syntax: setup' '
 	test_cmp expect actual
 '
 
+test_expect_success 'whitespace syntax: setup' '
+	test_create_repo space &&
+	test_commit -C space --author "A <[email protected]>" A &&
+	test_commit -C space --author "B <[email protected]>" B &&
+	test_commit -C space --author " C <[email protected]>" C &&
+	test_commit -C space --author " D  <[email protected]>" D &&
+	test_commit -C space --author "E E <[email protected]>" E &&
+	test_commit -C space --author "F  F <[email protected]>" F &&
+	test_commit -C space --author "G   G <[email protected]>" G &&
+	test_commit -C space --author "H   H <[email protected]>" H &&
+
+	test_config -C space mailmap.file ../space.map &&
+	cat >>space.map <<-\EOF &&
+	Ah <[email protected]> < [email protected] >
+	Bee <[email protected]  > <  [email protected]  >
+	Cee <[email protected]> C <[email protected]>
+	dee <[email protected]>  D  <[email protected]>
+	eee <[email protected]> E E <[email protected]>
+	eff <[email protected]> F  F <[email protected]>
+	gee <[email protected]> G   G <[email protected]>
+	aitch <[email protected]> H  H <[email protected]>
+	EOF
+
+	cat >expect <<-\EOF &&
+	Author A <[email protected]> maps to A <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author B <[email protected]> maps to B <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author C <[email protected]> maps to Cee <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author D <[email protected]> maps to dee <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author E E <[email protected]> maps to eee <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author F  F <[email protected]> maps to eff <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author G   G <[email protected]> maps to gee <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author H   H <[email protected]> maps to H   H <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+	EOF
+	git -C space 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_done
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#40 lore raw

PATCH 20/22 mailmap tests: add tests for empty "<>" syntax

In reply to Ævar Arnfjörð Bjarmason

Add tests for mailmap's handling of "<>", which is allowed on the RHS, but not the LHS of a "<LHS> <RHS>" pair.

---
 t/t4203-mailmap.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
t/t4203-mailmap.sh +27 -0
index 4f61655c04..f19736fef1 100755
@@ -838,4 +838,31 @@ test_expect_success 'whitespace syntax: setup' '
 	test_cmp expect actual
 '
 
+test_expect_success 'empty syntax: setup' '
+	test_create_repo empty &&
+	test_commit -C empty --author "A <>" A &&
+	test_commit -C empty --author "B <[email protected]>" B &&
+	test_commit -C empty --author "C <[email protected]>" C &&
+
+	test_config -C empty mailmap.file ../empty.map &&
+	cat >>empty.map <<-\EOF &&
+	Ah <[email protected]> <>
+	Bee <[email protected]> <>
+	Cee <> <[email protected]>
+	EOF
+
+	cat >expect <<-\EOF &&
+	Author A <> maps to Bee <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author B <[email protected]> maps to B <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+
+	Author C <[email protected]> maps to C <[email protected]>
+	Committer C O Mitter <[email protected]> maps to C O Mitter <[email protected]>
+	EOF
+	git -C empty 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_done
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#41 lore raw

PATCH 21/22 mailmap doc + tests: document and test for case-insensitivity

In reply to Ævar Arnfjörð Bjarmason

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/[email protected]/

---
 Documentation/gitmailmap.txt |  5 +++++
 t/t4203-mailmap.sh           | 14 ++++++++++++++
 2 files changed, 19 insertions(+)
Documentation/gitmailmap.txt +5 -0
index 55dfebd1b1..7f1089786d 100644
@@ -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 <[email protected]>' above:
+--
+Proper Name <[email protected]> CoMmIt NaMe <[email protected]>
+--
 
 EXAMPLES
 --------
t/t4203-mailmap.sh +14 -0
index f19736fef1..89cb300f28 100755
@@ -220,7 +220,21 @@ test_expect_success 'name entry after email entry, case-insensitive' '
 	      initial
 
 	EOF
+	git shortlog HEAD >actual &&
+	test_cmp expect actual &&
+
+	cat >internal.map <<-\EOF &&
+	NiCk <[email protected]> NICK1 <[email protected]>
+	EOF
+
+	cat >expect <<-\EOF &&
+	NiCk (1):
+	      second
+
+	Repo Guy (1):
+	      initial
 
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#42 lore raw

cover mailmap: doc + test fixes

In reply to Ævar Arnfjörð Bjarmason

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
Signature · 1 line
2.29.2.222.g5d2a92d10f8
#43 lore raw

Re: [PATCH 00/22] mailmap: doc + test fixes

Quoted 1 line · Ævar Arnfjörð Bjarmason

Just a "small" addition to v1, now with 21 extra patches. While this

Need reminder on what the v1 iteration was about here.

Thanks.

Quoted 2 lines

is a large series, it should be relatively easy to read and non-contentious.

I've read this series through and didn't find anything glaringly wrong or contentious. Very cleanly done.

Will queue.

#44 lore raw

Re: [PATCH 00/22] mailmap: doc + test fixes

Quoted 5 lines · Junio C Hamano
Quoted 1 line · Ævar Arnfjörð Bjarmason

Just a "small" addition to v1, now with 21 extra patches. While this

Need reminder on what the v1 iteration was about here.

Just the 22/22 patch for removing "repo-abbrev".

Quoted 5 lines
Quoted 2 lines

is a large series, it should be relatively easy to read and non-contentious.

I've read this series through and didn't find anything glaringly wrong or contentious. Very cleanly done.

Thanks, I saw you merged it down to "next" already. Should make any conflicts with other mailmap serieses short-lived.

#45 lore raw

cover mailmap: test cleanup

In reply to Ævar Arnfjörð Bjarmason

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(-)
Signature · 1 line
2.30.0.284.gd98b1dd5ea
#46 lore raw

PATCH 1/2 test-lib-functions.sh: fix usage for test_commit()

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>.

---
 t/test-lib-functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
t/test-lib-functions.sh +2 -2
index b0a5d74dc7..cea73cb8f0 100644
@@ -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.
Signature · 1 line
2.30.0.284.gd98b1dd5ea
#47 lore raw

Re: [PATCH 1/2] test-lib-functions.sh: fix usage for test_commit()

Quoted 7 lines · Denton Liu

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 :)

Quoted 21 lines
---
 t/test-lib-functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
t/test-lib-functions.sh +2 -2
index b0a5d74dc7..cea73cb8f0 100644
@@ -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.
#48 lore raw

PATCH 2/2 t4203: stop losing return codes of git commands

In reply to Denton Liu

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.

---
 t/t4203-mailmap.sh | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
t/t4203-mailmap.sh +14 -7
index 89cb300f28..c9cb1aa127 100755
@@ -634,7 +634,8 @@ test_expect_success 'Log output with --use-mailmap' '
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
 
-	git log --use-mailmap | grep Author >actual &&
+	git log --use-mailmap >log &&
+	grep Author log >actual &&
 	test_cmp expect actual
 '
 
@@ -651,7 +652,8 @@ test_expect_success 'Log output with log.mailmap' '
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
 
-	git -c log.mailmap=True log | grep Author >actual &&
+	git -c log.mailmap=True log >log &&
+	grep Author log >actual &&
 	test_cmp expect actual
 '
 
@@ -665,7 +667,8 @@ test_expect_success 'log.mailmap=false disables mailmap' '
 	Author: nick1 <[email protected]>
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
-	git -c log.mailmap=false log | grep Author >actual &&
+	git -c log.mailmap=false log >log &&
+	grep Author log >actual &&
 	test_cmp expect actual
 '
 
@@ -679,7 +682,8 @@ test_expect_success '--no-use-mailmap disables mailmap' '
 	Author: nick1 <[email protected]>
 	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	EOF
-	git log --no-use-mailmap | grep Author > actual &&
+	git log --no-use-mailmap >log &&
+	grep Author log >actual &&
 	test_cmp expect actual
 '
 
@@ -690,7 +694,8 @@ test_expect_success 'Grep author with --use-mailmap' '
 	Author: Santa Claus <[email protected]>
 	Author: Santa Claus <[email protected]>
 	EOF
-	git log --use-mailmap --author Santa | grep Author >actual &&
+	git log --use-mailmap --author Santa >log &&
+	grep Author log >actual &&
 	test_cmp expect actual
 '
 
@@ -702,13 +707,15 @@ test_expect_success 'Grep author with log.mailmap' '
 	Author: Santa Claus <[email protected]>
 	EOF
 
-	git -c log.mailmap=True log --author Santa | grep Author >actual &&
+	git -c log.mailmap=True log --author Santa >log &&
+	grep Author log >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'log.mailmap is true by default these days' '
 	test_config mailmap.file complex.map &&
-	git log --author Santa | grep Author >actual &&
+	git log --author Santa >log &&
+	grep Author log >actual &&
 	test_cmp expect actual
 '
 
Signature · 1 line
2.30.0.284.gd98b1dd5ea
#49 lore raw

Re: [PATCH 2/2] t4203: stop losing return codes of git commands

Quoted 4 lines · Denton Liu

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.

I tried to fix this in a much harder way today :)
https://lore.kernel.org/git/[email protected]/

But this is both easier and obviously correct, thanks!

#50 lore raw

PATCH 22/22 shortlog: remove unused(?) "repo-abbrev" feature

In reply to Ævar Arnfjörð Bjarmason

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 [email protected]: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/[email protected]/
5. https://lore.kernel.org/lkml/[email protected]/
6. https://lore.kernel.org/lkml/CAHk-=wg1+kf1AVzXA-RQX0zjM6t9J2Kay9xyuNqcFHWV-y5ZYw@mail.gmail.com/

---
 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(-)
builtin/blame.c +1 -1
index 6f7e32411a..712ae8e742 100644
@@ -1151,7 +1151,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
 	sb.xdl_opts = xdl_opts;
 	sb.no_whole_file_rename = no_whole_file_rename;
 
-	read_mailmap(&mailmap, NULL);
+	read_mailmap(&mailmap);
 
 	sb.found_guilty_entry = &found_guilty_entry;
 	sb.found_guilty_entry_data = &pi;
builtin/check-mailmap.c +1 -1
index cdce144f3b..7dc47e4793 100644
@@ -47,7 +47,7 @@ int cmd_check_mailmap(int argc, const char **argv, const char *prefix)
 	if (argc == 0 && !use_stdin)
 		die(_("no contacts specified"));
 
-	read_mailmap(&mailmap, NULL);
+	read_mailmap(&mailmap);
 
 	for (i = 0; i < argc; ++i)
 		check_mailmap(&mailmap, argv[i]);
builtin/commit.c +1 -1
index 505fe60956..739110c5a7 100644
@@ -1039,7 +1039,7 @@ static const char *find_author_by_nickname(const char *name)
 	av[++ac] = NULL;
 	setup_revisions(ac, av, &revs, NULL);
 	revs.mailmap = &mailmap;
-	read_mailmap(revs.mailmap, NULL);
+	read_mailmap(revs.mailmap);
 
 	if (prepare_revision_walk(&revs))
 		die(_("revision walk setup failed"));
builtin/log.c +1 -1
index bd6ff4f9f9..4ee81bc976 100644
@@ -230,7 +230,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 
 	if (mailmap) {
 		rev->mailmap = xcalloc(1, sizeof(struct string_list));
-		read_mailmap(rev->mailmap, NULL);
+		read_mailmap(rev->mailmap);
 	}
 
 	if (rev->pretty_given && rev->commit_format == CMIT_FMT_RAW) {
builtin/shortlog.c +2 -14
index c52e4ccd19..e7c21ab620 100644
@@ -61,8 +61,7 @@ static void insert_one_record(struct shortlog *log,
 	if (log->summary)
 		item->util = (void *)(UTIL_TO_INT(item) + 1);
 	else {
-		const char *dot3 = log->common_repo_prefix;
-		char *buffer, *p;
+		char *buffer;
 		struct strbuf subject = STRBUF_INIT;
 		const char *eol;
 
@@ -82,17 +81,6 @@ static void insert_one_record(struct shortlog *log,
 		format_subject(&subject, oneline, " ");
 		buffer = strbuf_detach(&subject, NULL);
 
-		if (dot3) {
-			int dot3len = strlen(dot3);
-			if (dot3len > 5) {
-				while ((p = strstr(buffer, dot3)) != NULL) {
-					int taillen = strlen(p) - dot3len;
-					memcpy(p, "/.../", 5);
-					memmove(p + 5, p + dot3len, taillen + 1);
-				}
-			}
-		}
-
 		if (item->util == NULL)
 			item->util = xcalloc(1, sizeof(struct string_list));
 		string_list_append(item->util, buffer);
@@ -342,7 +330,7 @@ void shortlog_init(struct shortlog *log)
 {
 	memset(log, 0, sizeof(*log));
 
-	read_mailmap(&log->mailmap, &log->common_repo_prefix);
+	read_mailmap(&log->mailmap);
 
 	log->list.strdup_strings = 1;
 	log->wrap = DEFAULT_WRAPLEN;
mailmap.c +13 -35

102 lines not on this page · raw message

mailmap.h +1 -1
index d0e65646cb..7e99fccb46 100644
@@ -3,7 +3,7 @@
 
 struct string_list;
 
-int read_mailmap(struct string_list *map, char **repo_abbrev);
+int read_mailmap(struct string_list *map);
 void clear_mailmap(struct string_list *map);
 
 int map_user(struct string_list *map,
pretty.c +1 -1
index 05eef7fda0..3922f6f9f2 100644
@@ -679,7 +679,7 @@ static int mailmap_name(const char **email, size_t *email_len,
 	static struct string_list *mail_map;
 	if (!mail_map) {
 		mail_map = xcalloc(1, sizeof(*mail_map));
-		read_mailmap(mail_map, NULL);
+		read_mailmap(mail_map);
 	}
 	return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
 }
shortlog.h +0 -1
index 64be879b24..3f7e9aabca 100644
@@ -23,7 +23,6 @@ struct shortlog {
 	} groups;
 	struct string_list trailers;
 
-	char *common_repo_prefix;
 	int email;
 	struct string_list mailmap;
 	FILE *file;
Signature · 1 line
2.29.2.222.g5d2a92d10f8