git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
* [PATCH 2/2] git-shortlog: make common repository prefix configurable with .mailmap
@ 2006-11-25  8:11 Junio C Hamano
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 50+ messages in thread
From: Junio C Hamano @ 2006-11-25  8:11 UTC (permalink / raw)
  To: git

The code had "/pub/scm/linux/kernel/git/" hardcoded which was
too specific to the kernel project.

With this, a line in the .mailmap file:

	# repo-abbrev: /pub/scm/linux/kernel/git/

can be used to cause the substring to be abbreviated to /.../
on the title line of the commit message.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 builtin-shortlog.c    |   24 ++++++++++++++++++++++--
 contrib/mailmap.linux |    2 ++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index bdd952c..b5b13de 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -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;
diff --git a/contrib/mailmap.linux b/contrib/mailmap.linux
index 83927c9..e4907f8 100644
--- a/contrib/mailmap.linux
+++ b/contrib/mailmap.linux
@@ -3,6 +3,8 @@
 # So have an email->real name table to translate the
 # (hopefully few) missing names
 #
+# repo-abbrev: /pub/scm/linux/kernel/git/
+#
 Adrian Bunk <bunk@stusta.de>
 Andreas Herrmann <aherrman@de.ibm.com>
 Andrew Morton <akpm@osdl.org>
-- 
1.4.4.1.g61fba


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH] shortlog: remove unused(?) "repo-abbrev" feature
  2006-11-25  8:11 [PATCH 2/2] git-shortlog: make common repository prefix configurable with .mailmap Junio C Hamano
@ 2021-01-05 13:03 ` Ævar Arnfjörð Bjarmason
  2021-01-05 19:18   ` Linus Torvalds
                     ` (25 more replies)
  0 siblings, 26 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-05 13:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Linus Torvalds, brian m . carlson,
	Æ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 --remote=git@gitlab.com:linux-kernel/linux.git \
        HEAD -- .mailmap | grep -a repo-abbrev
    # repo-abbrev: /pub/scm/linux/kernel/git/

Then when running e.g.:

    git shortlog --merges --author=Linus -1 v5.10-rc7..v5.10 | grep Merge

We'd emit (the [...] is mine):

      Merge tag [...]git://git.kernel.org/.../tip/tip

But will now emit:

      Merge tag [...]git.kernel.org/pub/scm/linux/kernel/git/tip/tip

I think at this point this is just a historical artifact we can get
rid of. It was initially meant for Linus's own use when we integrated
the Perl script[2], but since then it seems he's stopped using it.

Digging through Linus's release announcements on the LKML[3] the last
release I can find that made use of this output is Linux 2.6.25-rc6
back in March 2008[4]. Later on Linus started using --no-merges[5],
and nowadays seems to prefer some custom not-quite-shortlog format of
merges from lieutenants[6].

You will still see it on linux.git if you run "git shortlog" manually
yourself with --merges, with this removed you can still get the same
output with:

    git log --pretty=fuller v5.10-rc7..v5.10 |
    sed 's!/pub/scm/linux/kernel/git/!/.../!g' |
    git shortlog

Arguably we should do the same for the search-replacing of "[PATCH]"
at the beginning with "". That seems to be another relic of a bygone
era when linux.git patches would have their E-Mail subject lines
applied as-is by "git am" or whatever. But we documented that feature
in "git-shortlog(1)", and it seems more widely applicable than
something purely kernel-specific.

1. 7595e2ee6ef (git-shortlog: make common repository prefix
   configurable with .mailmap, 2006-11-25)
2. fa375c7f1b6 (Add git-shortlog perl script, 2005-06-04)
3. https://lore.kernel.org/lkml/
4. https://lore.kernel.org/lkml/alpine.LFD.1.00.0803161651350.3020@woody.linux-foundation.org/
5. https://lore.kernel.org/lkml/BANLkTinrbh7Xi27an3uY7pDWrNKhJRYmEA@mail.gmail.com/
6. https://lore.kernel.org/lkml/CAHk-=wg1+kf1AVzXA-RQX0zjM6t9J2Kay9xyuNqcFHWV-y5ZYw@mail.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@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(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 6f7e32411a8..712ae8e7425 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -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;
diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c
index cdce144f3b7..7dc47e47932 100644
--- a/builtin/check-mailmap.c
+++ b/builtin/check-mailmap.c
@@ -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]);
diff --git a/builtin/commit.c b/builtin/commit.c
index 505fe60956d..739110c5a7f 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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"));
diff --git a/builtin/log.c b/builtin/log.c
index bd6ff4f9f95..4ee81bc976d 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -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) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index c52e4ccd19a..e7c21ab6201 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -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;
diff --git a/mailmap.c b/mailmap.c
index 962fd86d6d7..f1da233adb9 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -143,31 +143,10 @@ static char *parse_name_and_email(char *buffer, char **name,
 	return (*right == '\0' ? NULL : right);
 }
 
-static void read_mailmap_line(struct string_list *map, char *buffer,
-			      char **repo_abbrev)
+static void read_mailmap_line(struct string_list *map, char *buffer)
 {
 	char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
-	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;
-
-			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);
 
@@ -175,8 +154,7 @@ static void read_mailmap_line(struct string_list *map, char *buffer,
 		add_mapping(map, name1, email1, name2, email2);
 }
 
-static int read_mailmap_file(struct string_list *map, const char *filename,
-			     char **repo_abbrev)
+static int read_mailmap_file(struct string_list *map, const char *filename)
 {
 	char buffer[1024];
 	FILE *f;
@@ -192,13 +170,12 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
 	}
 
 	while (fgets(buffer, sizeof(buffer), f) != NULL)
-		read_mailmap_line(map, buffer, repo_abbrev);
+		read_mailmap_line(map, buffer);
 	fclose(f);
 	return 0;
 }
 
-static void read_mailmap_string(struct string_list *map, char *buf,
-				char **repo_abbrev)
+static void read_mailmap_string(struct string_list *map, char *buf)
 {
 	while (*buf) {
 		char *end = strchrnul(buf, '\n');
@@ -206,14 +183,12 @@ static void read_mailmap_string(struct string_list *map, char *buf,
 		if (*end)
 			*end++ = '\0';
 
-		read_mailmap_line(map, buf, repo_abbrev);
+		read_mailmap_line(map, buf);
 		buf = end;
 	}
 }
 
-static int read_mailmap_blob(struct string_list *map,
-			     const char *name,
-			     char **repo_abbrev)
+static int read_mailmap_blob(struct string_list *map, const char *name)
 {
 	struct object_id oid;
 	char *buf;
@@ -231,13 +206,13 @@ static int read_mailmap_blob(struct string_list *map,
 	if (type != OBJ_BLOB)
 		return error("mailmap is not a blob: %s", name);
 
-	read_mailmap_string(map, buf, repo_abbrev);
+	read_mailmap_string(map, buf);
 
 	free(buf);
 	return 0;
 }
 
-int read_mailmap(struct string_list *map, char **repo_abbrev)
+int read_mailmap(struct string_list *map)
 {
 	int err = 0;
 
@@ -247,10 +222,10 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)
 	if (!git_mailmap_blob && is_bare_repository())
 		git_mailmap_blob = "HEAD:.mailmap";
 
-	err |= read_mailmap_file(map, ".mailmap", repo_abbrev);
+	err |= read_mailmap_file(map, ".mailmap");
 	if (startup_info->have_repository)
-		err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
-	err |= read_mailmap_file(map, git_mailmap_file, repo_abbrev);
+		err |= read_mailmap_blob(map, git_mailmap_blob);
+	err |= read_mailmap_file(map, git_mailmap_file);
 	return err;
 }
 
diff --git a/mailmap.h b/mailmap.h
index d0e65646cb5..7e99fccb46c 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -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,
diff --git a/pretty.c b/pretty.c
index 7a7708a0ea7..fe0a66623e3 100644
--- a/pretty.c
+++ b/pretty.c
@@ -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);
 }
diff --git a/shortlog.h b/shortlog.h
index 64be879b241..3f7e9aabcae 100644
--- a/shortlog.h
+++ b/shortlog.h
@@ -23,7 +23,6 @@ struct shortlog {
 	} groups;
 	struct string_list trailers;
 
-	char *common_repo_prefix;
 	int email;
 	struct string_list mailmap;
 	FILE *file;
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH] shortlog: remove unused(?) "repo-abbrev" feature
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
@ 2021-01-05 19:18   ` Linus Torvalds
  2021-01-05 21:15   ` Martin Ågren
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Linus Torvalds @ 2021-01-05 19:18 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Git List Mailing, Junio C Hamano, brian m . carlson

On Tue, Jan 5, 2021 at 5:04 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
> Remove support for the magical "repo-abbrev" comment in .mailmap
> files. This was added to .mailmap parsing in [1], as a generalized
> feature of the git-shortlog Perl script added earlier in [2].

Ack. As you found out, I haven't used this in ages.

           Linus

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH] shortlog: remove unused(?) "repo-abbrev" feature
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
  2021-01-05 19:18   ` Linus Torvalds
@ 2021-01-05 21:15   ` Martin Ågren
  2021-01-05 23:06   ` Junio C Hamano
                     ` (23 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Martin Ågren @ 2021-01-05 21:15 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Git Mailing List, Junio C Hamano, Linus Torvalds, brian m . carlson

Hi Ævar,

On Tue, 5 Jan 2021 at 14:32, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>  {
>         char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
> -       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;
> -
> -                       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:

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 586c3a86b1..4d461ad343 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -373,6 +373,7 @@ test_expect_success 'Shortlog output (complex mapping)' '
        echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap &&
        echo "<cto@company.xx>
<cto@coompany.xx>" >> internal_mailmap/.mailmap &&
        echo "Some Dude <some@dude.xx>         nick1
<bugs@company.xx>" >> internal_mailmap/.mailmap &&
+       echo "# Comment <no@mail.xx>         nick1 <bugs@company.xx>"
>> internal_mailmap/.mailmap &&
        echo "Other Author <other@author.xx>   nick2
<bugs@company.xx>" >> internal_mailmap/.mailmap &&
        echo "Other Author <other@author.xx>
<nick2@company.xx>" >> internal_mailmap/.mailmap &&
        echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>"
>> internal_mailmap/.mailmap &&

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

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH] shortlog: remove unused(?) "repo-abbrev" feature
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
  2021-01-05 19:18   ` Linus Torvalds
  2021-01-05 21:15   ` Martin Ågren
@ 2021-01-05 23:06   ` Junio C Hamano
  2021-01-12 20:17   ` [PATCH 00/22] mailmap: doc + test fixes Ævar Arnfjörð Bjarmason
                     ` (22 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Junio C Hamano @ 2021-01-05 23:06 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Linus Torvalds, brian m . carlson

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Remove support for the magical "repo-abbrev" comment in .mailmap
> files. This was added to .mailmap parsing in [1], as a generalized
> feature of the git-shortlog Perl script added earlier in [2].
> ...
> I wondered what this repo-abbrev thing was while reading thorugh
> recent mailmap.c traffic. I was a bit on the fence about this being a
> RFC/PATCH, but I guess if people hate this & want to keep it that's
> fine, but if not this should be ready for inclusion.
>
> Surely has some conflicts with brian's recent submission, but I wanted
> to get it out of my queue sooner than later.

I'd expect that nobody would say anything until this change hits a
released version, and then after another release or two when it hits a
binary-packaged distro release, we may hear a regression report.  

Or perhaps not.

In other words, we won't see a complaint (other than any obvious ones
we'd notice during review, like "shouldn't we be skipping comments?")
by cooking this in 'next', so I'd prefer to fast-track a topic like this
quickly to 'master' but make sure we can revert it anytime.  Which in
turn means that it would be nice to see it while the codepaths involved
is expected to be quiet for a while.  So, let's ignore this topic while
the other mailmap topic is in flight and then revisit it after it
graduates to 'master'.

Thanks.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 00/22] mailmap: doc + test fixes
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (2 preceding siblings ...)
  2021-01-05 23:06   ` Junio C Hamano
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 22:34     ` Junio C Hamano
  2021-01-14 23:02     ` [PATCH 0/2] mailmap: test cleanup Denton Liu
  2021-01-12 20:17   ` [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page Ævar Arnfjörð Bjarmason
                     ` (21 subsequent siblings)
  25 siblings, 2 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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

-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (3 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 00/22] mailmap: doc + test fixes Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-14 17:41     ` Philippe Blain
  2021-01-15  2:34     ` [PATCH] fixup! " Philippe Blain
  2021-01-12 20:17   ` [PATCH 02/22] mailmap doc: quote config variables `like.this` Ævar Arnfjörð Bjarmason
                     ` (20 subsequent siblings)
  25 siblings, 2 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 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%)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index b980407059..81d1bf7a04 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -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
diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index 34b496d485..3bf5d5d8b4 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -226,7 +226,7 @@ commit commentary), a blame viewer will not care.
 MAPPING AUTHORS
 ---------------
 
-include::mailmap.txt[]
+See linkgit:gitmailmap[5].
 
 
 SEE ALSO
diff --git a/Documentation/git-check-mailmap.txt b/Documentation/git-check-mailmap.txt
index aa2055dbeb..45a5cfafd8 100644
--- a/Documentation/git-check-mailmap.txt
+++ b/Documentation/git-check-mailmap.txt
@@ -39,7 +39,7 @@ printed; otherwise only ``$$<user@host>$$'' is printed.
 MAPPING AUTHORS
 ---------------
 
-include::mailmap.txt[]
+See linkgit:gitmailmap[5].
 
 
 GIT
diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt
index fd93cd41e9..c16cc3b608 100644
--- a/Documentation/git-shortlog.txt
+++ b/Documentation/git-shortlog.txt
@@ -111,11 +111,7 @@ include::rev-list-options.txt[]
 MAPPING AUTHORS
 ---------------
 
-The `.mailmap` feature is used to coalesce together commits by the same
-person in the shortlog, where their name and/or email address was
-spelled differently.
-
-include::mailmap.txt[]
+See linkgit:gitmailmap[5].
 
 GIT
 ---
diff --git a/Documentation/mailmap.txt b/Documentation/gitmailmap.txt
similarity index 88%
rename from Documentation/mailmap.txt
rename to Documentation/gitmailmap.txt
index 4a8c276529..8b07f9c5d7 100644
--- a/Documentation/mailmap.txt
+++ b/Documentation/gitmailmap.txt
@@ -1,9 +1,28 @@
+gitmailmap(5)
+=============
+
+NAME
+----
+gitmailmap - Map author/committer names and/or E-Mail addresses
+
+SYNOPSIS
+--------
+$GIT_WORK_DIR/.mailmap
+
+
+DESCRIPTION
+-----------
+
 If the file `.mailmap` exists at the toplevel of the repository, or at
 the location pointed to by the mailmap.file or mailmap.blob
 configuration options, it
 is used to map author and committer names and email addresses to
 canonical real names and email addresses.
 
+
+SYNTAX
+------
+
 In the simple form, each line in the file consists of the canonical
 real name of an author, whitespace, and an email address used in the
 commit (enclosed by '<' and '>') to map to the name. For example:
@@ -27,6 +46,10 @@ commit matching the specified commit email address, and:
 which allows mailmap to replace both the name and the email of a
 commit matching both the specified commit name and email address.
 
+
+EXAMPLES
+--------
+
 Example 1: Your history contains commits by two authors, Jane
 and Joe, whose names appear in the repository under several forms:
 
@@ -73,3 +96,13 @@ Santa Claus <santa.claus@northpole.xx> <me@company.xx>
 
 Use hash '#' for comments that are either on their own line, or after
 the email address.
+
+
+SEE ALSO
+--------
+linkgit:git-check-mailmap[1]
+
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/command-list.txt b/command-list.txt
index 9379b02e5e..a289f09ed6 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -204,6 +204,7 @@ gitfaq                                  guide
 gitglossary                             guide
 githooks                                guide
 gitignore                               guide
+gitmailmap                              guide
 gitmodules                              guide
 gitnamespaces                           guide
 gitremote-helpers                       guide
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 02/22] mailmap doc: quote config variables `like.this`
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (4 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 03/22] check-mailmap doc: note config options Ævar Arnfjörð Bjarmason
                     ` (19 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/gitmailmap.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/gitmailmap.txt b/Documentation/gitmailmap.txt
index 8b07f9c5d7..e75eadde63 100644
--- a/Documentation/gitmailmap.txt
+++ b/Documentation/gitmailmap.txt
@@ -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.
 
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 03/22] check-mailmap doc: note config options
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (5 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 02/22] mailmap doc: quote config variables `like.this` Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 04/22] mailmap doc: start by mentioning the comment syntax Ævar Arnfjörð Bjarmason
                     ` (18 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/git-check-mailmap.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/git-check-mailmap.txt b/Documentation/git-check-mailmap.txt
index 45a5cfafd8..02f4418323 100644
--- a/Documentation/git-check-mailmap.txt
+++ b/Documentation/git-check-mailmap.txt
@@ -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
 ---------------
 
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 04/22] mailmap doc: start by mentioning the comment syntax
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (6 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 03/22] check-mailmap doc: note config options Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 05/22] mailmap tests: use our preferred whitespace syntax Ævar Arnfjörð Bjarmason
                     ` (17 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/gitmailmap.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/gitmailmap.txt b/Documentation/gitmailmap.txt
index e75eadde63..4e4677018b 100644
--- a/Documentation/gitmailmap.txt
+++ b/Documentation/gitmailmap.txt
@@ -23,6 +23,9 @@ canonical real names and email addresses.
 SYNTAX
 ------
 
+The '#' character begins a comment to the end of line, blank lines
+are ignored.
+
 In the simple form, each line in the file consists of the canonical
 real name of an author, whitespace, and an email address used in the
 commit (enclosed by '<' and '>') to map to the name. For example:
@@ -94,8 +97,6 @@ Other Author <other@author.xx>         <nick2@company.xx>
 Santa Claus <santa.claus@northpole.xx> <me@company.xx>
 ------------
 
-Use hash '#' for comments that are either on their own line, or after
-the email address.
 
 
 SEE ALSO
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 05/22] mailmap tests: use our preferred whitespace syntax
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (7 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 04/22] mailmap doc: start by mentioning the comment syntax Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 06/22] mailmap tests: modernize syntax & test idioms Ævar Arnfjörð Bjarmason
                     ` (16 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 586c3a86b1..034a78aba1 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -13,7 +13,7 @@ fuzz_blame () {
 }
 
 test_expect_success setup '
-	cat >contacts <<- EOF &&
+	cat >contacts <<-EOF &&
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
 	nick1 <bugs@company.xx>
 	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 <bugs@company.xx>
 	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 <bugs@company.xx>
 	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 <bugs@company.xx>
 	EOF
-	cat >both <<- EOF &&
+	cat >both <<-EOF &&
 	Blob Guy <$GIT_AUTHOR_EMAIL>
 	Blob Guy <bugs@company.xx>
 	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 <cto@coompany.xx>
 	Author: claus <me@company.xx>
 	Author: santa <me@company.xx>
@@ -480,12 +480,12 @@ test_expect_success 'log.mailmap=false disables mailmap' '
 	Author: nick1 <bugs@company.xx>
 	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 <cto@coompany.xx>
 	Author: claus <me@company.xx>
 	Author: santa <me@company.xx>
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 06/22] mailmap tests: modernize syntax & test idioms
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (8 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 05/22] mailmap tests: use our preferred whitespace syntax Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-14  7:51     ` Denton Liu
  2021-01-12 20:17   ` [PATCH 07/22] mailmap tests: improve --stdin tests Ævar Arnfjörð Bjarmason
                     ` (15 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 473 ++++++++++++++++++++++++++-------------------
 1 file changed, 274 insertions(+), 199 deletions(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 034a78aba1..61d1b62317 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 <bugs@company.xx>
@@ -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 <bugs@company.xx>
+	EOF
 
-EOF
-test_expect_success 'mailmap.file set' '
-	mkdir -p internal_mailmap &&
-	echo "Internal Guy <bugs@company.xx>" > 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 <bugs@company.xx>
+	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 &&
+	<bugs@company.xy> <bugs@company.xx>
+	Internal Guy <bugs@company.xx>
+	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 "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
-	echo "Internal Guy <bugs@company.xx>" >>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 &&
+	<bugs@company.xy> <bugs@company.xx>
+	Internal Guy <BUGS@Company.xx>
+	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 "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
-	echo "Internal Guy <BUGS@Company.xx>" >>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 <bugs@company.xx>" >>expect &&
-	echo "A <$GIT_AUTHOR_EMAIL>" >.mailmap &&
 	test_when_finished "rm .mailmap" &&
+	cat >.mailmap <<-EOF &&
+	A <$GIT_AUTHOR_EMAIL>
+	EOF
+
+	cat >expect <<-EOF &&
+	     1	A <$GIT_AUTHOR_EMAIL>
+	     1	nick1 <bugs@company.xx>
+	EOF
 	git shortlog -es HEAD >actual &&
 	test_cmp expect actual
 '
 
 test_expect_success 'preserve canonical email case' '
-	echo "     1	$GIT_AUTHOR_NAME <AUTHOR@example.com>" >expect &&
-	echo "     1	nick1 <bugs@company.xx>" >>expect &&
-	echo "<AUTHOR@example.com> <$GIT_AUTHOR_EMAIL>" >.mailmap &&
 	test_when_finished "rm .mailmap" &&
+	cat >.mailmap <<-EOF &&
+	<AUTHOR@example.com> <$GIT_AUTHOR_EMAIL>
+	EOF
+
+	cat >expect <<-EOF &&
+	     1	$GIT_AUTHOR_NAME <AUTHOR@example.com>
+	     1	nick1 <bugs@company.xx>
+	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 <cto@company.xx> (1):
-      seventh
-
-Other Author <other@author.xx> (2):
-      third
-      fourth
-
-Santa Claus <santa.claus@northpole.xx> (2):
-      fifth
-      sixth
-
-Some Dude <some@dude.xx> (1):
-      second
-
-EOF
-
 test_expect_success 'Shortlog output (complex mapping)' '
+	test_config mailmap.file complex.map &&
+	cat >complex.map <<-EOF &&
+	Committed <$GIT_COMMITTER_EMAIL>
+	<cto@company.xx> <cto@coompany.xx>
+	Some Dude <some@dude.xx>         nick1 <bugs@company.xx>
+	Other Author <other@author.xx>   nick2 <bugs@company.xx>
+	Other Author <other@author.xx>         <nick2@company.xx>
+	Santa Claus <santa.claus@northpole.xx> <me@company.xx>
+	Santa Claus <santa.claus@northpole.xx> <me@company.xx>
+	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 <cto@coompany.xx>" -m seventh &&
 
-	mkdir -p internal_mailmap &&
-	echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap &&
-	echo "<cto@company.xx>                       <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
-	echo "Some Dude <some@dude.xx>         nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
-	echo "Other Author <other@author.xx>   nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
-	echo "Other Author <other@author.xx>         <nick2@company.xx>" >> internal_mailmap/.mailmap &&
-	echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
-	echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
+	cat >expect <<-EOF &&
+	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
+	      initial
+
+	CTO <cto@company.xx> (1):
+	      seventh
+
+	Other Author <other@author.xx> (2):
+	      third
+	      fourth
+
+	Santa Claus <santa.claus@northpole.xx> (2):
+	      fifth
+	      sixth
+
+	Some Dude <some@dude.xx> (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 <cto@coompany.xx> maps to CTO <cto@company.xx>
-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 <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	cat >expect <<-EOF &&
+	Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
+	Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
 
-Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>
-Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
+	Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
+	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 <bugs@company.xx> maps to Some Dude <some@dude.xx>
+	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 cto@coompany.xx 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 cto@coompany.xx has local-part cto
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email me@company.xx has local-part me
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email me@company.xx has local-part me
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email me@company.xx has local-part me
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email me@company.xx has local-part me
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email nick2@company.xx has local-part nick2
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email nick2@company.xx has local-part nick2
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email bugs@company.xx has local-part bugs
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email bugs@company.xx has local-part bugs
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email bugs@company.xx has local-part bugs
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
+	Author email bugs@company.xx has local-part bugs
+	Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
 
-Author email author@example.com has local-part author
-Committer email $GIT_COMMITTER_EMAIL has local-part $TEST_COMMITTER_LOCALNAME
-EOF
+	Author email author@example.com 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 <cto@company.xx>
-Author: Santa Claus <santa.claus@northpole.xx>
-Author: Santa Claus <santa.claus@northpole.xx>
-Author: Other Author <other@author.xx>
-Author: Other Author <other@author.xx>
-Author: Some Dude <some@dude.xx>
-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 <cto@company.xx>
+	Author: Santa Claus <santa.claus@northpole.xx>
+	Author: Santa Claus <santa.claus@northpole.xx>
+	Author: Other Author <other@author.xx>
+	Author: Other Author <other@author.xx>
+	Author: Some Dude <some@dude.xx>
+	Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+	EOF
+
 	git log --use-mailmap | grep Author >actual &&
 	test_cmp expect actual
 '
 
-cat >expect << EOF
-Author: CTO <cto@company.xx>
-Author: Santa Claus <santa.claus@northpole.xx>
-Author: Santa Claus <santa.claus@northpole.xx>
-Author: Other Author <other@author.xx>
-Author: Other Author <other@author.xx>
-Author: Some Dude <some@dude.xx>
-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 <cto@company.xx>
+	Author: Santa Claus <santa.claus@northpole.xx>
+	Author: Santa Claus <santa.claus@northpole.xx>
+	Author: Other Author <other@author.xx>
+	Author: Other Author <other@author.xx>
+	Author: Some Dude <some@dude.xx>
+	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 <bugs@company.xx>
 	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 <santa.claus@northpole.xx>
-Author: Santa Claus <santa.claus@northpole.xx>
-EOF
-
 test_expect_success 'Grep author with --use-mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Author: Santa Claus <santa.claus@northpole.xx>
+	Author: Santa Claus <santa.claus@northpole.xx>
+	EOF
 	git log --use-mailmap --author Santa | grep Author >actual &&
 	test_cmp expect actual
 '
-cat >expect <<\EOF
-Author: Santa Claus <santa.claus@northpole.xx>
-Author: Santa Claus <santa.claus@northpole.xx>
-EOF
 
 test_expect_success 'Grep author with log.mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Author: Santa Claus <santa.claus@northpole.xx>
+	Author: Santa Claus <santa.claus@northpole.xx>
+	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 "<cto@coompany.xx>" >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 <some@dude.xx>
-EOF
-
 test_expect_success 'commit --author honors mailmap' '
+	test_config mailmap.file complex.map &&
+
+	cat >expect <<-\EOF &&
+	Some Dude <some@dude.xx>
+	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 &&
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 07/22] mailmap tests: improve --stdin tests
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (9 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 06/22] mailmap tests: modernize syntax & test idioms Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 08/22] mailmap tests: remove redundant entry in test Ævar Arnfjörð Bjarmason
                     ` (14 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 40 ++++++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 61d1b62317..dbd365681e 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -13,11 +13,6 @@ fuzz_blame () {
 }
 
 test_expect_success 'setup commits and contacts file' '
-	cat >contacts <<-EOF &&
-	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
-	nick1 <bugs@company.xx>
-	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 <bugs@company.xx>
 	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 <bugs@company.xx>
+	EOF
 	cat >expect <<-\EOF &&
 	Internal Guy <bugs@company.xy>
 	EOF
-	cat <contacts >>expect &&
+	cat contacts >>expect &&
+
 	git check-mailmap --stdin "Internal Guy <bugs@company.xy>" \
 		<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):
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 08/22] mailmap tests: remove redundant entry in test
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (10 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 07/22] mailmap tests: improve --stdin tests Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 09/22] mailmap tests: add a test for "not a blob" error Ævar Arnfjörð Bjarmason
                     ` (13 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index dbd365681e..03a98d9635 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -414,7 +414,6 @@ test_expect_success 'Shortlog output (complex mapping)' '
 	Other Author <other@author.xx>   nick2 <bugs@company.xx>
 	Other Author <other@author.xx>         <nick2@company.xx>
 	Santa Claus <santa.claus@northpole.xx> <me@company.xx>
-	Santa Claus <santa.claus@northpole.xx> <me@company.xx>
 	EOF
 
 	echo three >>one &&
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 09/22] mailmap tests: add a test for "not a blob" error
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (11 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 08/22] mailmap tests: remove redundant entry in test Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 22:34     ` Junio C Hamano
  2021-01-12 20:17   ` [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing Ævar Arnfjörð Bjarmason
                     ` (12 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 03a98d9635..78d56e0566 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 &&
 	(
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (12 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 09/22] mailmap tests: add a test for "not a blob" error Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 22:34     ` Junio C Hamano
  2021-01-12 20:17   ` [PATCH 11/22] mailmap: test for silent exiting on missing file/blob Ævar Arnfjörð Bjarmason
                     ` (11 subsequent siblings)
  25 siblings, 1 reply; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 50 +++++++++++++++++++++++++++-------------------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 78d56e0566..a42b454756 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 &&
 
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 11/22] mailmap: test for silent exiting on missing file/blob
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (13 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 12/22] test-lib functions: expand "test_commit" comment template Ævar Arnfjörð Bjarmason
                     ` (10 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index a42b454756..2b342d7f7c 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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
 '
 
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 12/22] test-lib functions: expand "test_commit" comment template
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (14 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 11/22] mailmap: test for silent exiting on missing file/blob Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 13/22] test-lib functions: document arguments to test_commit Ævar Arnfjörð Bjarmason
                     ` (9 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/test-lib-functions.sh | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 999982fe4a..396e039d2a 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -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= &&
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 13/22] test-lib functions: document arguments to test_commit
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (15 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 12/22] test-lib functions: expand "test_commit" comment template Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:17   ` [PATCH 14/22] test-lib functions: add --author support " Ævar Arnfjörð Bjarmason
                     ` (8 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/test-lib-functions.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 396e039d2a..194b601bc0 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -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.
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 14/22] test-lib functions: add --author support to test_commit
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (16 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 13/22] test-lib functions: document arguments to test_commit Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 22:34     ` Junio C Hamano
  2021-01-14  7:40     ` Denton Liu
  2021-01-12 20:17   ` [PATCH 15/22] test-lib functions: add an --append option " Ævar Arnfjörð Bjarmason
                     ` (7 subsequent siblings)
  25 siblings, 2 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t7509-commit-authorship.sh |  7 ++-----
 t/test-lib-functions.sh      | 11 ++++++++++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/t/t7509-commit-authorship.sh b/t/t7509-commit-authorship.sh
index 500ab2fe72..ee6c47416e 100755
--- a/t/t7509-commit-authorship.sh
+++ b/t/t7509-commit-authorship.sh
@@ -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\ \<flying@over.world\> &&
-	git tag Initial &&
+	test_commit --author Frigate\ \<flying@over.world\> \
+		"Initial Commit" foo Initial Initial &&
 	echo "Test 1" >>foo &&
 	test_tick &&
 	git commit -a -C Initial &&
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 194b601bc0..529f6264fe 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -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}"
 }
 
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 15/22] test-lib functions: add an --append option to test_commit
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (17 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 14/22] test-lib functions: add --author support " Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:17   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:18   ` [PATCH 16/22] tests: refactor a few tests to use "test_commit --append" Ævar Arnfjörð Bjarmason
                     ` (6 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:17 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh      | 39 +++++++--------------------------------
 t/test-lib-functions.sh | 14 +++++++++++++-
 2 files changed, 20 insertions(+), 33 deletions(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 2b342d7f7c..5d92880a5a 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 <bugs@company.xx>" -m second
+	test_commit initial one one &&
+	test_commit --author "nick1 <bugs@company.xx>" --append second one two
 '
 
 test_expect_success 'check-mailmap no arguments' '
@@ -436,30 +430,11 @@ test_expect_success 'Shortlog output (complex mapping)' '
 	Santa Claus <santa.claus@northpole.xx> <me@company.xx>
 	EOF
 
-	echo three >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "nick2 <bugs@company.xx>" -m third &&
-
-	echo four >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "nick2 <nick2@company.xx>" -m fourth &&
-
-	echo five >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "santa <me@company.xx>" -m fifth &&
-
-	echo six >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "claus <me@company.xx>" -m sixth &&
-
-	echo seven >>one &&
-	git add one &&
-	test_tick &&
-	git commit --author "CTO <cto@coompany.xx>" -m seventh &&
+	test_commit --author "nick2 <bugs@company.xx>" --append third one three &&
+	test_commit --author "nick2 <nick2@company.xx>" --append fourth one four &&
+	test_commit --author "santa <me@company.xx>" --append fifth one five &&
+	test_commit --author "claus <me@company.xx>" --append sixth one six &&
+	test_commit --author "CTO <cto@coompany.xx>" --append seventh one seven &&
 
 	cat >expect <<-EOF &&
 	$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 529f6264fe..b0a5d74dc7 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -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
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 16/22] tests: refactor a few tests to use "test_commit --append"
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (18 preceding siblings ...)
  2021-01-12 20:17   ` [PATCH 15/22] test-lib functions: add an --append option " Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:18   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:18   ` [PATCH 17/22] mailmap doc + tests: add better examples & test them Ævar Arnfjörð Bjarmason
                     ` (5 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:18 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t1412-reflog-loop.sh   |  7 ++-----
 t/t2012-checkout-last.sh | 12 +++---------
 t/t7810-grep.sh          | 18 +++---------------
 3 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/t/t1412-reflog-loop.sh b/t/t1412-reflog-loop.sh
index 3acd895afb..977603f7f1 100755
--- a/t/t1412-reflog-loop.sh
+++ b/t/t1412-reflog-loop.sh
@@ -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' '
diff --git a/t/t2012-checkout-last.sh b/t/t2012-checkout-last.sh
index e7ba8c505f..c95aa3e78f 100755
--- a/t/t2012-checkout-last.sh
+++ b/t/t2012-checkout-last.sh
@@ -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' '
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index 991d5bd9c0..312e0f8cb4 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -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="xyzzy@frotz.com" \
-	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="nitfol@frobozz.com" \
-	git commit -a -m "fourth"
+	test_commit --append --author "With * Asterisk <xyzzy@frotz.com>" second file a &&
+	test_commit --append third file a &&
+	test_commit --append --author "Night Fall <nitfol@frobozz.com>" fourth file a
 '
 
 test_expect_success 'log grep (1)' '
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 17/22] mailmap doc + tests: add better examples & test them
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (19 preceding siblings ...)
  2021-01-12 20:18   ` [PATCH 16/22] tests: refactor a few tests to use "test_commit --append" Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:18   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:18   ` [PATCH 18/22] mailmap tests: add a test for comment syntax Ævar Arnfjörð Bjarmason
                     ` (4 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:18 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

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

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


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 18/22] mailmap tests: add a test for comment syntax
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (20 preceding siblings ...)
  2021-01-12 20:18   ` [PATCH 17/22] mailmap doc + tests: add better examples & test them Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:18   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:18   ` [PATCH 19/22] mailmap tests: add tests for whitespace syntax Ævar Arnfjörð Bjarmason
                     ` (3 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:18 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Ævar Arnfjörð Bjarmason,
	Martin Ågren

Add a test for mailmap comment syntax. As noted in [1] there was no
test coverage for this. Let's make sure a future change doesn't break
it.

1. https://lore.kernel.org/git/CAN0heSoKYWXqskCR=GPreSHc6twCSo1345WTmiPdrR57XSShhA@mail.gmail.com/

Reported-by: Martin Ågren <martin.agren@gmail.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 96ba5367c6..10e672e006 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 <a@example.com>" A &&
+	test_commit -C comm --author "B <b@example.com>" 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 <a@example.com>
+
+	; Bee <b@example.com>
+	Cee <cee@example.com> <#@example.com>
+	Dee <dee@example.com> <d@e#ample.com>
+	EOF
+
+	cat >expect <<-\EOF &&
+	Author A <a@example.com> maps to A <a@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author B <b@example.com> maps to ; Bee <b@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author C <#@example.com> maps to Cee <cee@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author D <d@e#ample.com> maps to Dee <dee@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+	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
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 19/22] mailmap tests: add tests for whitespace syntax
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (21 preceding siblings ...)
  2021-01-12 20:18   ` [PATCH 18/22] mailmap tests: add a test for comment syntax Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:18   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:18   ` [PATCH 20/22] mailmap tests: add tests for empty "<>" syntax Ævar Arnfjörð Bjarmason
                     ` (2 subsequent siblings)
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:18 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Ævar Arnfjörð Bjarmason

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

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 10e672e006..4f61655c04 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 <a@example.com>" A &&
+	test_commit -C space --author "B <b@example.com>" B &&
+	test_commit -C space --author " C <c@example.com>" C &&
+	test_commit -C space --author " D  <d@example.com>" D &&
+	test_commit -C space --author "E E <e@example.com>" E &&
+	test_commit -C space --author "F  F <f@example.com>" F &&
+	test_commit -C space --author "G   G <g@example.com>" G &&
+	test_commit -C space --author "H   H <h@example.com>" H &&
+
+	test_config -C space mailmap.file ../space.map &&
+	cat >>space.map <<-\EOF &&
+	Ah <ah@example.com> < a@example.com >
+	Bee <bee@example.com  > <  b@example.com  >
+	Cee <cee@example.com> C <c@example.com>
+	dee <dee@example.com>  D  <d@example.com>
+	eee <eee@example.com> E E <e@example.com>
+	eff <eff@example.com> F  F <f@example.com>
+	gee <gee@example.com> G   G <g@example.com>
+	aitch <aitch@example.com> H  H <h@example.com>
+	EOF
+
+	cat >expect <<-\EOF &&
+	Author A <a@example.com> maps to A <a@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author B <b@example.com> maps to B <b@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author C <c@example.com> maps to Cee <cee@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author D <d@example.com> maps to dee <dee@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author E E <e@example.com> maps to eee <eee@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author F  F <f@example.com> maps to eff <eff@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author G   G <g@example.com> maps to gee <gee@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author H   H <h@example.com> maps to H   H <h@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+	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
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 20/22] mailmap tests: add tests for empty "<>" syntax
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (22 preceding siblings ...)
  2021-01-12 20:18   ` [PATCH 19/22] mailmap tests: add tests for whitespace syntax Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:18   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:18   ` [PATCH 21/22] mailmap doc + tests: document and test for case-insensitivity Ævar Arnfjörð Bjarmason
  2021-01-12 20:18   ` [PATCH 22/22] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:18 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t4203-mailmap.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 4f61655c04..f19736fef1 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 <b@example.com>" B &&
+	test_commit -C empty --author "C <c@example.com>" C &&
+
+	test_config -C empty mailmap.file ../empty.map &&
+	cat >>empty.map <<-\EOF &&
+	Ah <ah@example.com> <>
+	Bee <bee@example.com> <>
+	Cee <> <c@example.com>
+	EOF
+
+	cat >expect <<-\EOF &&
+	Author A <> maps to Bee <bee@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author B <b@example.com> maps to B <b@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+	Author C <c@example.com> maps to C <c@example.com>
+	Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+	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
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 21/22] mailmap doc + tests: document and test for case-insensitivity
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (23 preceding siblings ...)
  2021-01-12 20:18   ` [PATCH 20/22] mailmap tests: add tests for empty "<>" syntax Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:18   ` Ævar Arnfjörð Bjarmason
  2021-01-12 20:18   ` [PATCH 22/22] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:18 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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/87czykvg19.fsf@evledraar.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/gitmailmap.txt |  5 +++++
 t/t4203-mailmap.sh           | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/Documentation/gitmailmap.txt b/Documentation/gitmailmap.txt
index 55dfebd1b1..7f1089786d 100644
--- a/Documentation/gitmailmap.txt
+++ b/Documentation/gitmailmap.txt
@@ -49,6 +49,11 @@ commit matching the specified commit email address, and:
 which allows mailmap to replace both the name and the email of a
 commit matching both the specified commit name and email address.
 
+Both E-Mails and names are matched case-insensitively. For example
+this would also match the 'Commit Name <commit@email.xx>' above:
+--
+Proper Name <proper@email.xx> CoMmIt NaMe <CoMmIt@EmAiL.xX>
+--
 
 EXAMPLES
 --------
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index f19736fef1..89cb300f28 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 <BuGs@CoMpAnY.Xy> NICK1 <BUGS@COMPANY.XX>
+	EOF
+
+	cat >expect <<-\EOF &&
+	NiCk (1):
+	      second
+
+	Repo Guy (1):
+	      initial
 
+	EOF
 	git shortlog HEAD >actual &&
 	test_cmp expect actual
 '
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 22/22] shortlog: remove unused(?) "repo-abbrev" feature
  2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
                     ` (24 preceding siblings ...)
  2021-01-12 20:18   ` [PATCH 21/22] mailmap doc + tests: document and test for case-insensitivity Ævar Arnfjörð Bjarmason
@ 2021-01-12 20:18   ` Ævar Arnfjörð Bjarmason
  25 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-12 20:18 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Ævar Arnfjörð Bjarmason,
	Linus Torvalds

Remove support for the magical "repo-abbrev" comment in .mailmap
files. This was added to .mailmap parsing in [1], as a generalized
feature of the git-shortlog Perl script added earlier in [2].

There was no documentation or tests for this feature, and I don't
think it's used in practice anymore.

What it did was to allow you to specify a single string to be
search-replaced with "/.../" in the .mailmap file. E.g. for
linux.git's current .mailmap:

    git archive --remote=git@gitlab.com:linux-kernel/linux.git \
        HEAD -- .mailmap | grep -a repo-abbrev
    # repo-abbrev: /pub/scm/linux/kernel/git/

Then when running e.g.:

    git shortlog --merges --author=Linus -1 v5.10-rc7..v5.10 | grep Merge

We'd emit (the [...] is mine):

      Merge tag [...]git://git.kernel.org/.../tip/tip

But will now emit:

      Merge tag [...]git.kernel.org/pub/scm/linux/kernel/git/tip/tip

I think at this point this is just a historical artifact we can get
rid of. It was initially meant for Linus's own use when we integrated
the Perl script[2], but since then it seems he's stopped using it.

Digging through Linus's release announcements on the LKML[3] the last
release I can find that made use of this output is Linux 2.6.25-rc6
back in March 2008[4]. Later on Linus started using --no-merges[5],
and nowadays seems to prefer some custom not-quite-shortlog format of
merges from lieutenants[6].

You will still see it on linux.git if you run "git shortlog" manually
yourself with --merges, with this removed you can still get the same
output with:

    git log --pretty=fuller v5.10-rc7..v5.10 |
    sed 's!/pub/scm/linux/kernel/git/!/.../!g' |
    git shortlog

Arguably we should do the same for the search-replacing of "[PATCH]"
at the beginning with "". That seems to be another relic of a bygone
era when linux.git patches would have their E-Mail subject lines
applied as-is by "git am" or whatever. But we documented that feature
in "git-shortlog(1)", and it seems more widely applicable than
something purely kernel-specific.

1. 7595e2ee6ef (git-shortlog: make common repository prefix
   configurable with .mailmap, 2006-11-25)
2. fa375c7f1b6 (Add git-shortlog perl script, 2005-06-04)
3. https://lore.kernel.org/lkml/
4. https://lore.kernel.org/lkml/alpine.LFD.1.00.0803161651350.3020@woody.linux-foundation.org/
5. https://lore.kernel.org/lkml/BANLkTinrbh7Xi27an3uY7pDWrNKhJRYmEA@mail.gmail.com/
6. https://lore.kernel.org/lkml/CAHk-=wg1+kf1AVzXA-RQX0zjM6t9J2Kay9xyuNqcFHWV-y5ZYw@mail.gmail.com/

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@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(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 6f7e32411a..712ae8e742 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -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;
diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c
index cdce144f3b..7dc47e4793 100644
--- a/builtin/check-mailmap.c
+++ b/builtin/check-mailmap.c
@@ -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]);
diff --git a/builtin/commit.c b/builtin/commit.c
index 505fe60956..739110c5a7 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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"));
diff --git a/builtin/log.c b/builtin/log.c
index bd6ff4f9f9..4ee81bc976 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -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) {
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index c52e4ccd19..e7c21ab620 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -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;
diff --git a/mailmap.c b/mailmap.c
index 962fd86d6d..eb77c6e77c 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -143,31 +143,13 @@ static char *parse_name_and_email(char *buffer, char **name,
 	return (*right == '\0' ? NULL : right);
 }
 
-static void read_mailmap_line(struct string_list *map, char *buffer,
-			      char **repo_abbrev)
+static void read_mailmap_line(struct string_list *map, char *buffer)
 {
 	char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
-	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;
-
-			free(*repo_abbrev);
-
-			for (cp = buffer + abblen; isspace(*cp); cp++)
-				; /* nothing */
-			*repo_abbrev = xstrdup(cp);
-		}
+	if (buffer[0] == '#')
 		return;
-	}
+
 	if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
 		parse_name_and_email(name2, &name2, &email2, 1);
 
@@ -175,8 +157,7 @@ static void read_mailmap_line(struct string_list *map, char *buffer,
 		add_mapping(map, name1, email1, name2, email2);
 }
 
-static int read_mailmap_file(struct string_list *map, const char *filename,
-			     char **repo_abbrev)
+static int read_mailmap_file(struct string_list *map, const char *filename)
 {
 	char buffer[1024];
 	FILE *f;
@@ -192,13 +173,12 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
 	}
 
 	while (fgets(buffer, sizeof(buffer), f) != NULL)
-		read_mailmap_line(map, buffer, repo_abbrev);
+		read_mailmap_line(map, buffer);
 	fclose(f);
 	return 0;
 }
 
-static void read_mailmap_string(struct string_list *map, char *buf,
-				char **repo_abbrev)
+static void read_mailmap_string(struct string_list *map, char *buf)
 {
 	while (*buf) {
 		char *end = strchrnul(buf, '\n');
@@ -206,14 +186,12 @@ static void read_mailmap_string(struct string_list *map, char *buf,
 		if (*end)
 			*end++ = '\0';
 
-		read_mailmap_line(map, buf, repo_abbrev);
+		read_mailmap_line(map, buf);
 		buf = end;
 	}
 }
 
-static int read_mailmap_blob(struct string_list *map,
-			     const char *name,
-			     char **repo_abbrev)
+static int read_mailmap_blob(struct string_list *map, const char *name)
 {
 	struct object_id oid;
 	char *buf;
@@ -231,13 +209,13 @@ static int read_mailmap_blob(struct string_list *map,
 	if (type != OBJ_BLOB)
 		return error("mailmap is not a blob: %s", name);
 
-	read_mailmap_string(map, buf, repo_abbrev);
+	read_mailmap_string(map, buf);
 
 	free(buf);
 	return 0;
 }
 
-int read_mailmap(struct string_list *map, char **repo_abbrev)
+int read_mailmap(struct string_list *map)
 {
 	int err = 0;
 
@@ -247,10 +225,10 @@ int read_mailmap(struct string_list *map, char **repo_abbrev)
 	if (!git_mailmap_blob && is_bare_repository())
 		git_mailmap_blob = "HEAD:.mailmap";
 
-	err |= read_mailmap_file(map, ".mailmap", repo_abbrev);
+	err |= read_mailmap_file(map, ".mailmap");
 	if (startup_info->have_repository)
-		err |= read_mailmap_blob(map, git_mailmap_blob, repo_abbrev);
-	err |= read_mailmap_file(map, git_mailmap_file, repo_abbrev);
+		err |= read_mailmap_blob(map, git_mailmap_blob);
+	err |= read_mailmap_file(map, git_mailmap_file);
 	return err;
 }
 
diff --git a/mailmap.h b/mailmap.h
index d0e65646cb..7e99fccb46 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -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,
diff --git a/pretty.c b/pretty.c
index 05eef7fda0..3922f6f9f2 100644
--- a/pretty.c
+++ b/pretty.c
@@ -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);
 }
diff --git a/shortlog.h b/shortlog.h
index 64be879b24..3f7e9aabca 100644
--- a/shortlog.h
+++ b/shortlog.h
@@ -23,7 +23,6 @@ struct shortlog {
 	} groups;
 	struct string_list trailers;
 
-	char *common_repo_prefix;
 	int email;
 	struct string_list mailmap;
 	FILE *file;
-- 
2.29.2.222.g5d2a92d10f8


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 00/22] mailmap: doc + test fixes
  2021-01-12 20:17   ` [PATCH 00/22] mailmap: doc + test fixes Ævar Arnfjörð Bjarmason
@ 2021-01-12 22:34     ` Junio C Hamano
  2021-01-14  8:59       ` Ævar Arnfjörð Bjarmason
  2021-01-14 23:02     ` [PATCH 0/2] mailmap: test cleanup Denton Liu
  1 sibling, 1 reply; 50+ messages in thread
From: Junio C Hamano @ 2021-01-12 22:34 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Johannes Sixt, Johannes Schindelin, brian m . carlson

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

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

Need reminder on what the v1 iteration was about here.  

Thanks.

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

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/22] test-lib functions: add --author support to test_commit
  2021-01-12 20:17   ` [PATCH 14/22] test-lib functions: add --author support " Ævar Arnfjörð Bjarmason
@ 2021-01-12 22:34     ` Junio C Hamano
  2021-01-14  7:40     ` Denton Liu
  1 sibling, 0 replies; 50+ messages in thread
From: Junio C Hamano @ 2021-01-12 22:34 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Johannes Sixt, Johannes Schindelin, brian m . carlson

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Add support for --author to "test_commit". This will simplify some
> current and future tests, one of those is being changed here.
>
> Let's also line-wrap the "git commit" command invocation to make diffs
> that add subsequent options easier to add, as they'll only need to add
> a new option line.

Makes sense.

> -	git commit -m "Initial Commit" --author Frigate\ \<flying@over.world\> &&
> -	git tag Initial &&
> +	test_commit --author Frigate\ \<flying@over.world\> \
> +		"Initial Commit" foo Initial Initial &&

Why not fix the value of the author while at it to be more readable?
E.g. --author "Frigate <flying@over.world>"

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing
  2021-01-12 20:17   ` [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing Ævar Arnfjörð Bjarmason
@ 2021-01-12 22:34     ` Junio C Hamano
  2021-01-14 20:21       ` Junio C Hamano
  0 siblings, 1 reply; 50+ messages in thread
From: Junio C Hamano @ 2021-01-12 22:34 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Johannes Sixt, Johannes Schindelin, brian m . carlson

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

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

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 09/22] mailmap tests: add a test for "not a blob" error
  2021-01-12 20:17   ` [PATCH 09/22] mailmap tests: add a test for "not a blob" error Ævar Arnfjörð Bjarmason
@ 2021-01-12 22:34     ` Junio C Hamano
  0 siblings, 0 replies; 50+ messages in thread
From: Junio C Hamano @ 2021-01-12 22:34 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Johannes Sixt, Johannes Schindelin, brian m . carlson

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Add a test for one of the error conditions added in
> 938a60d64f (mailmap: clean up read_mailmap error handling,
> 2012-12-12).
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  t/t4203-mailmap.sh | 9 +++++++++
>  1 file changed, 9 insertions(+)

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

> diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
> index 03a98d9635..78d56e0566 100755
> --- a/t/t4203-mailmap.sh
> +++ b/t/t4203-mailmap.sh
> @@ -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 &&
>  	(

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/22] test-lib functions: add --author support to test_commit
  2021-01-12 20:17   ` [PATCH 14/22] test-lib functions: add --author support " Ævar Arnfjörð Bjarmason
  2021-01-12 22:34     ` Junio C Hamano
@ 2021-01-14  7:40     ` Denton Liu
  1 sibling, 0 replies; 50+ messages in thread
From: Denton Liu @ 2021-01-14  7:40 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson

Hi Ævar,

On Tue, Jan 12, 2021 at 09:17:58PM +0100, Ævar Arnfjörð Bjarmason wrote:
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index 194b601bc0..529f6264fe 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -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...

> +#	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"

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

Thanks,
Denton

> +			shift
> +			;;
>  		--signoff)
>  			signoff="$1"
>  			;;

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 06/22] mailmap tests: modernize syntax & test idioms
  2021-01-12 20:17   ` [PATCH 06/22] mailmap tests: modernize syntax & test idioms Ævar Arnfjörð Bjarmason
@ 2021-01-14  7:51     ` Denton Liu
  2021-01-14 20:00       ` Junio C Hamano
  0 siblings, 1 reply; 50+ messages in thread
From: Denton Liu @ 2021-01-14  7:51 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson

Hi Ævar,

On Tue, Jan 12, 2021 at 09:17:50PM +0100, Ævar Arnfjörð Bjarmason wrote:
> @@ -480,7 +545,7 @@ test_expect_success 'log.mailmap=false disables mailmap' '
>  	Author: nick1 <bugs@company.xx>
>  	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

>  	test_cmp expect actual
>  '

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 00/22] mailmap: doc + test fixes
  2021-01-12 22:34     ` Junio C Hamano
@ 2021-01-14  8:59       ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-14  8:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Sixt, Johannes Schindelin, brian m . carlson


On Tue, Jan 12 2021, Junio C Hamano wrote:

> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> 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".

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

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page
  2021-01-12 20:17   ` [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page Ævar Arnfjörð Bjarmason
@ 2021-01-14 17:41     ` Philippe Blain
  2021-01-14 19:58       ` Junio C Hamano
  2021-01-15  2:34     ` [PATCH] fixup! " Philippe Blain
  1 sibling, 1 reply; 50+ messages in thread
From: Philippe Blain @ 2021-01-14 17:41 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason, git
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin, brian m . carlson

Hi Ævar,

Le 2021-01-12 à 15:17, Ævar Arnfjörð Bjarmason a écrit :
> Create a gitmailmap(5) page similar to how .gitmodules and .gitignore
> have their own pages at gitmodules(5) and gitignore(5). Now instead of
> "check-mailmap", "blame" and "shortlog" documentation including the
> description of the format we link to one canonical place.
> 
> This makes things easier for readers, since in our manpage or
> web-based[1] output it's not clear that the "MAPPING AUTHORS" sections
> aren't subtly different, as opposed to just included.
> 
> 1. https://git-scm.com/docs/git-check-mailmap

I think that's a good idea.

> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>   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 :)

>   6 files changed, 38 insertions(+), 7 deletions(-)
>   rename Documentation/{mailmap.txt => gitmailmap.txt} (88%)
> 

-- 8< --

> diff --git a/Documentation/mailmap.txt b/Documentation/gitmailmap.txt
> similarity index 88%
> rename from Documentation/mailmap.txt
> rename to Documentation/gitmailmap.txt
> index 4a8c276529..8b07f9c5d7 100644
> --- a/Documentation/mailmap.txt
> +++ b/Documentation/gitmailmap.txt
> @@ -1,9 +1,28 @@
> +gitmailmap(5)
> +=============
> +
> +NAME
> +----
> +gitmailmap - Map author/committer names and/or E-Mail addresses
> +
> +SYNOPSIS
> +--------
> +$GIT_WORK_DIR/.mailmap

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

Also, if you feel like this new guide should be featured in the "Guides" column
at git-scm.com/docs, I encourage you to submit a PR to the website. Though
I think for this specific guide, simply having it listed in git(1), linked from the
"All guides..." link at the bottom of that column, is sufficient.

Cheers,

Philippe.

[1] https://lore.kernel.org/git/pull.942.v2.git.git.1609695736001.gitgitgadget@gmail.com/

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page
  2021-01-14 17:41     ` Philippe Blain
@ 2021-01-14 19:58       ` Junio C Hamano
  2021-01-15  2:38         ` Philippe Blain
  0 siblings, 1 reply; 50+ messages in thread
From: Junio C Hamano @ 2021-01-14 19:58 UTC (permalink / raw)
  To: Philippe Blain
  Cc: Ævar Arnfjörð Bjarmason, git, Johannes Sixt,
	Johannes Schindelin, brian m . carlson

Philippe Blain <levraiphilippeblain@gmail.com> writes:

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

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 06/22] mailmap tests: modernize syntax & test idioms
  2021-01-14  7:51     ` Denton Liu
@ 2021-01-14 20:00       ` Junio C Hamano
  0 siblings, 0 replies; 50+ messages in thread
From: Junio C Hamano @ 2021-01-14 20:00 UTC (permalink / raw)
  To: Denton Liu
  Cc: Ævar Arnfjörð Bjarmason, git, Johannes Sixt,
	Johannes Schindelin, brian m . carlson

Denton Liu <liu.denton@gmail.com> writes:

> On Tue, Jan 12, 2021 at 09:17:50PM +0100, Ævar Arnfjörð Bjarmason wrote:
>> @@ -480,7 +545,7 @@ test_expect_success 'log.mailmap=false disables mailmap' '
>>  	Author: nick1 <bugs@company.xx>
>>  	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.

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.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing
  2021-01-12 22:34     ` Junio C Hamano
@ 2021-01-14 20:21       ` Junio C Hamano
  0 siblings, 0 replies; 50+ messages in thread
From: Junio C Hamano @ 2021-01-14 20:21 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Johannes Sixt, Johannes Schindelin, brian m . carlson

Junio C Hamano <gitster@pobox.com> writes:

> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> +	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.

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.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4203-mailmap.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git c/t/t4203-mailmap.sh i/t/t4203-mailmap.sh
index 89cb300f28..d4a6e73736 100755
--- c/t/t4203-mailmap.sh
+++ i/t/t4203-mailmap.sh
@@ -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
 '
 


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 0/2] mailmap: test cleanup
  2021-01-12 20:17   ` [PATCH 00/22] mailmap: doc + test fixes Ævar Arnfjörð Bjarmason
  2021-01-12 22:34     ` Junio C Hamano
@ 2021-01-14 23:02     ` Denton Liu
  2021-01-14 23:02       ` [PATCH 1/2] test-lib-functions.sh: fix usage for test_commit() Denton Liu
  2021-01-14 23:02       ` [PATCH 2/2] t4203: stop losing return codes of git commands Denton Liu
  1 sibling, 2 replies; 50+ messages in thread
From: Denton Liu @ 2021-01-14 23:02 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Æ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(-)

-- 
2.30.0.284.gd98b1dd5ea


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 1/2] test-lib-functions.sh: fix usage for test_commit()
  2021-01-14 23:02     ` [PATCH 0/2] mailmap: test cleanup Denton Liu
@ 2021-01-14 23:02       ` Denton Liu
  2021-01-15  0:19         ` Ævar Arnfjörð Bjarmason
  2021-01-14 23:02       ` [PATCH 2/2] t4203: stop losing return codes of git commands Denton Liu
  1 sibling, 1 reply; 50+ messages in thread
From: Denton Liu @ 2021-01-14 23:02 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Ævar Arnfjörð Bjarmason

The usage comment for test_commit() shows that the --author option
should be given as `--author=<author>`. However, this is incorrect as it
only works when given as `--author <author>`. Correct this erroneous
text.

Also, for the sake of correctness, fix the description as well since we
invoke `git commit` with `--author <author>`, not `--author=<author>`.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/test-lib-functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index b0a5d74dc7..cea73cb8f0 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -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.
-- 
2.30.0.284.gd98b1dd5ea


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 2/2] t4203: stop losing return codes of git commands
  2021-01-14 23:02     ` [PATCH 0/2] mailmap: test cleanup Denton Liu
  2021-01-14 23:02       ` [PATCH 1/2] test-lib-functions.sh: fix usage for test_commit() Denton Liu
@ 2021-01-14 23:02       ` Denton Liu
  2021-01-15  0:20         ` Ævar Arnfjörð Bjarmason
  1 sibling, 1 reply; 50+ messages in thread
From: Denton Liu @ 2021-01-14 23:02 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Johannes Sixt, Johannes Schindelin,
	brian m . carlson, Ævar Arnfjörð Bjarmason

In a pipe, only the return code of the last command is used. Thus, all
other commands will have their return codes masked. Rewrite pipes so
that there are no git commands upstream so that their failure is
reported.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t4203-mailmap.sh | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 89cb300f28..c9cb1aa127 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -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 <bugs@company.xx>
 	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 <bugs@company.xx>
 	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 <santa.claus@northpole.xx>
 	Author: Santa Claus <santa.claus@northpole.xx>
 	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 <santa.claus@northpole.xx>
 	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
 '
 
-- 
2.30.0.284.gd98b1dd5ea


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 1/2] test-lib-functions.sh: fix usage for test_commit()
  2021-01-14 23:02       ` [PATCH 1/2] test-lib-functions.sh: fix usage for test_commit() Denton Liu
@ 2021-01-15  0:19         ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-15  0:19 UTC (permalink / raw)
  To: Denton Liu
  Cc: Git Mailing List, Junio C Hamano, Johannes Sixt,
	Johannes Schindelin, brian m . carlson


On Fri, Jan 15 2021, Denton Liu wrote:

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

>
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
>  t/test-lib-functions.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index b0a5d74dc7..cea73cb8f0 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -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.


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 2/2] t4203: stop losing return codes of git commands
  2021-01-14 23:02       ` [PATCH 2/2] t4203: stop losing return codes of git commands Denton Liu
@ 2021-01-15  0:20         ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 50+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-01-15  0:20 UTC (permalink / raw)
  To: Denton Liu
  Cc: Git Mailing List, Junio C Hamano, Johannes Sixt,
	Johannes Schindelin, brian m . carlson


On Fri, Jan 15 2021, Denton Liu wrote:

> 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/20210114233515.31298-1-avarab@gmail.com/

But this is both easier and obviously correct, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH] fixup! mailmap doc: create a new "gitmailmap(5)" man page
  2021-01-12 20:17   ` [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page Ævar Arnfjörð Bjarmason
  2021-01-14 17:41     ` Philippe Blain
@ 2021-01-15  2:34     ` Philippe Blain
  2021-01-15  3:28       ` [PATCH v2] mailmap doc: use correct environment variable 'GIT_WORK_TREE' Philippe Blain
  1 sibling, 1 reply; 50+ messages in thread
From: Philippe Blain @ 2021-01-15  2:34 UTC (permalink / raw)
  To: git; +Cc: avarab, j6t, Johannes.Schindelin, sandals, gitster

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 Documentation/gitmailmap.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/gitmailmap.txt b/Documentation/gitmailmap.txt
index 7f1089786d..052209b33b 100644
--- a/Documentation/gitmailmap.txt
+++ b/Documentation/gitmailmap.txt
@@ -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
-- 
2.29.2


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page
  2021-01-14 19:58       ` Junio C Hamano
@ 2021-01-15  2:38         ` Philippe Blain
  2021-01-15  3:18           ` Junio C Hamano
  0 siblings, 1 reply; 50+ messages in thread
From: Philippe Blain @ 2021-01-15  2:38 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Ævar Arnfjörð Bjarmason, git, Johannes Sixt,
	Johannes Schindelin, brian m . carlson

Hi Junio

Le 2021-01-14 à 14:58, Junio C Hamano a écrit :
> Philippe Blain <levraiphilippeblain@gmail.com> writes:
> 
>>> +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?
> 

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/87zh1b51xk.fsf@evledraar.gmail.com/T/#m9e8e8f5458db71153c2363acf4bff959df7d0f4c

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page
  2021-01-15  2:38         ` Philippe Blain
@ 2021-01-15  3:18           ` Junio C Hamano
  2021-01-15  3:36             ` Philippe Blain
  0 siblings, 1 reply; 50+ messages in thread
From: Junio C Hamano @ 2021-01-15  3:18 UTC (permalink / raw)
  To: Philippe Blain
  Cc: Ævar Arnfjörð Bjarmason, git, Johannes Sixt,
	Johannes Schindelin, brian m . carlson

Philippe Blain <levraiphilippeblain@gmail.com> writes:

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


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH v2] mailmap doc: use correct environment variable 'GIT_WORK_TREE'
  2021-01-15  2:34     ` [PATCH] fixup! " Philippe Blain
@ 2021-01-15  3:28       ` Philippe Blain
  0 siblings, 0 replies; 50+ messages in thread
From: Philippe Blain @ 2021-01-15  3:28 UTC (permalink / raw)
  To: git; +Cc: avarab, j6t, Johannes.Schindelin, sandals, gitster

gitmailmap(5) uses 'GIT_WORK_DIR' to refer to the root of the
repository, but this environment variable does not exist.

Use the correct spelling for that variable, 'GIT_WORK_TREE'.

Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
 Documentation/gitmailmap.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/gitmailmap.txt b/Documentation/gitmailmap.txt
index 7f1089786d..052209b33b 100644
--- a/Documentation/gitmailmap.txt
+++ b/Documentation/gitmailmap.txt
@@ -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
-- 
2.29.2


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page
  2021-01-15  3:18           ` Junio C Hamano
@ 2021-01-15  3:36             ` Philippe Blain
  2021-01-15  5:53               ` Junio C Hamano
  0 siblings, 1 reply; 50+ messages in thread
From: Philippe Blain @ 2021-01-15  3:36 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Ævar Arnfjörð Bjarmason, git, Johannes Sixt,
	Johannes Schindelin, brian m . carlson


Le 2021-01-14 à 22:18, Junio C Hamano a écrit :
> Philippe Blain <levraiphilippeblain@gmail.com> writes:
> 
>> 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/20210115032826.51369-1-levraiphilippeblain@gmail.com/

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page
  2021-01-15  3:36             ` Philippe Blain
@ 2021-01-15  5:53               ` Junio C Hamano
  0 siblings, 0 replies; 50+ messages in thread
From: Junio C Hamano @ 2021-01-15  5:53 UTC (permalink / raw)
  To: Philippe Blain
  Cc: Ævar Arnfjörð Bjarmason, git, Johannes Sixt,
	Johannes Schindelin, brian m . carlson

Philippe Blain <levraiphilippeblain@gmail.com> writes:

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

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2021-01-15  5:54 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-25  8:11 [PATCH 2/2] git-shortlog: make common repository prefix configurable with .mailmap Junio C Hamano
2021-01-05 13:03 ` [PATCH] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason
2021-01-05 19:18   ` Linus Torvalds
2021-01-05 21:15   ` Martin Ågren
2021-01-05 23:06   ` Junio C Hamano
2021-01-12 20:17   ` [PATCH 00/22] mailmap: doc + test fixes Ævar Arnfjörð Bjarmason
2021-01-12 22:34     ` Junio C Hamano
2021-01-14  8:59       ` Ævar Arnfjörð Bjarmason
2021-01-14 23:02     ` [PATCH 0/2] mailmap: test cleanup Denton Liu
2021-01-14 23:02       ` [PATCH 1/2] test-lib-functions.sh: fix usage for test_commit() Denton Liu
2021-01-15  0:19         ` Ævar Arnfjörð Bjarmason
2021-01-14 23:02       ` [PATCH 2/2] t4203: stop losing return codes of git commands Denton Liu
2021-01-15  0:20         ` Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 01/22] mailmap doc: create a new "gitmailmap(5)" man page Ævar Arnfjörð Bjarmason
2021-01-14 17:41     ` Philippe Blain
2021-01-14 19:58       ` Junio C Hamano
2021-01-15  2:38         ` Philippe Blain
2021-01-15  3:18           ` Junio C Hamano
2021-01-15  3:36             ` Philippe Blain
2021-01-15  5:53               ` Junio C Hamano
2021-01-15  2:34     ` [PATCH] fixup! " Philippe Blain
2021-01-15  3:28       ` [PATCH v2] mailmap doc: use correct environment variable 'GIT_WORK_TREE' Philippe Blain
2021-01-12 20:17   ` [PATCH 02/22] mailmap doc: quote config variables `like.this` Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 03/22] check-mailmap doc: note config options Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 04/22] mailmap doc: start by mentioning the comment syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 05/22] mailmap tests: use our preferred whitespace syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 06/22] mailmap tests: modernize syntax & test idioms Ævar Arnfjörð Bjarmason
2021-01-14  7:51     ` Denton Liu
2021-01-14 20:00       ` Junio C Hamano
2021-01-12 20:17   ` [PATCH 07/22] mailmap tests: improve --stdin tests Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 08/22] mailmap tests: remove redundant entry in test Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 09/22] mailmap tests: add a test for "not a blob" error Ævar Arnfjörð Bjarmason
2021-01-12 22:34     ` Junio C Hamano
2021-01-12 20:17   ` [PATCH 10/22] mailmap tests: get rid of overly complex blame fuzzing Ævar Arnfjörð Bjarmason
2021-01-12 22:34     ` Junio C Hamano
2021-01-14 20:21       ` Junio C Hamano
2021-01-12 20:17   ` [PATCH 11/22] mailmap: test for silent exiting on missing file/blob Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 12/22] test-lib functions: expand "test_commit" comment template Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 13/22] test-lib functions: document arguments to test_commit Ævar Arnfjörð Bjarmason
2021-01-12 20:17   ` [PATCH 14/22] test-lib functions: add --author support " Ævar Arnfjörð Bjarmason
2021-01-12 22:34     ` Junio C Hamano
2021-01-14  7:40     ` Denton Liu
2021-01-12 20:17   ` [PATCH 15/22] test-lib functions: add an --append option " Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 16/22] tests: refactor a few tests to use "test_commit --append" Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 17/22] mailmap doc + tests: add better examples & test them Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 18/22] mailmap tests: add a test for comment syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 19/22] mailmap tests: add tests for whitespace syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 20/22] mailmap tests: add tests for empty "<>" syntax Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 21/22] mailmap doc + tests: document and test for case-insensitivity Ævar Arnfjörð Bjarmason
2021-01-12 20:18   ` [PATCH 22/22] shortlog: remove unused(?) "repo-abbrev" feature Ævar Arnfjörð Bjarmason

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git