{"thread":{"id":"62011","subject":"[PATCH v3 0/3] send-email: add --mailmap support","startedAt":"2024-08-27T21:27:32Z","lastAt":"2024-08-28T21:23:47Z","messageCount":6,"participants":["Jacob Keller","Junio C Hamano","Josh Steadmon"],"isPatch":true,"patchVersion":3,"patchTotal":3},"messages":[{"id":"501736","messageId":"20240827-jk-send-email-mailmap-support-v3-0-bec5ba9be391@gmail.com","threadId":"62011","inReplyTo":null,"subject":"[PATCH v3 0/3] send-email: add --mailmap support","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2024-08-27T21:27:15Z","receivedAt":"2024-08-27T21:27:32Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"I recently sent a series to enable mailmap support in format patch. The\ndiscussion led me to realize that the true problem we wanted solved is to\nmap addresses at send time, so that we do not accidentally include a dead\nmail address when sending an old change.\n\nInstead of worrying about what the formatted patch has, this series\nimplements support for mailmap at the send-email, which will translate all\naddresses, and not just the author/commit addresses for a patch, but also\nthe email for any trailers.o\n\nSince v2, we now have a configuration option (sendemail.mailmap) to enable\nthis behavior. In addition, I enabled support for email-specific mailmap\nfiles.\n\nThe intention of these is to allow a maintainer to map the known-dead\naddresses of former colleagues onto a current email for an owner within the\nteam. This would be used to update the send addresses to avoid including\nno-longer-valid addresses when sending patches. This is intended for cases\nwhere the original author is no longer valid such as when they are no\nlonger employed to work on the project. While sometimes pointing to a\ncanonical public address of that person may make sense, in other contexts,\nremoving them from the email makes sense.\n\nI believe this version solves the use case we have of ensuring that we stop\nsending emails with invalid addresses, and may be useful for others as\nwell.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\nChanges in v3:\n- Edit description of patch 1 to clarify lack of validation of email\n  addresses.\n- Update tests for check-mailmap, removing the bogus contact tests entirely.\n- Link to v2: https://lore.kernel.org/r/20240819-jk-send-email-mailmap-support-v2-0-d212c3f9e505@gmail.com\n\nChanges in v2:\n- Loosen restriction on git check-mailmap by default, rather than\n  introducing a specific --no-brackets option.\n- Re-write commit message for the send-email changes.\n- Add --mailmap-file and --mailmap-blob options to git check-mailmap.\n- Add configuration options to git send-email for enabling mailmap support\n  by default, as well as providing send-email specific mailmap files.\n- Link to v1: https://lore.kernel.org/r/20240816-jk-send-email-mailmap-support-v1-0-68ca5b4a6078@gmail.com\n- Link to previous \"v0\": https://lore.kernel.org/r/20240813-jk-support-mailmap-git-format-patch-v1-1-1aea690ea5dd@gmail.com\n\n---\nJacob Keller (3):\n      check-mailmap: accept \"user@host\" contacts\n      check-mailmap: add options for additional mailmap sources\n      send-email: add mailmap support via sendemail.mailmap and --mailmap\n\n mailmap.h                           |   7 +++\n builtin/check-mailmap.c             |  25 +++++---\n mailmap.c                           |   9 +--\n Documentation/git-check-mailmap.txt |  18 ++++--\n git-send-email.perl                 |  20 ++++++\n t/t4203-mailmap.sh                  |  42 +++++++++++--\n t/t9001-send-email.sh               | 122 ++++++++++++++++++++++++++++++++++++\n 7 files changed, 222 insertions(+), 21 deletions(-)\n---\nbase-commit: 87a1768b93a67d0420255a43d9e07387b2e805ad\nchange-id: 20240816-jk-send-email-mailmap-support-1a9e86867c72\n\nBest regards,\n-- \nJacob Keller <jacob.keller@gmail.com>\n\n"},{"id":"501737","messageId":"20240827-jk-send-email-mailmap-support-v3-1-bec5ba9be391@gmail.com","threadId":"62011","inReplyTo":"20240827-jk-send-email-mailmap-support-v3-0-bec5ba9be391@gmail.com","subject":"[PATCH v3 1/3] check-mailmap: accept \"user@host\" contacts","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2024-08-27T21:27:16Z","receivedAt":"2024-08-27T21:27:34Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\ngit check-mailmap splits each provided contact using split_ident_line.\nThis function requires that the contact either be of the form \"Name\n<user@host>\" or of the form \"<user@host>\". In particular, if the mail\nportion of the contact is not surrounded by angle brackets,\nsplit_ident_line will reject it.\n\nThis results in git check-mailmap rejecting attempts to translate simple\nemail addresses:\n\n  $ git check-mailmap user@host\n  fatal: unable to parse contact: user@host\n\nThis limits the usability of check-mailmap as it requires placing angle\nbrackets around plain email addresses.\n\nIn particular, attempting to use git check-mailmap to support mapping\naddresses in git send-email is not straight forward. The sanitization\nand validation functions in git send-email strip angle brackets from\nplain email addresses. It is not trivial to add brackets prior to\ninvoking git check-mailmap.\n\nInstead, modify check_mailmap() to allow such strings as contacts. In\nparticular, treat any line which cannot be split by split_ident_line as\na simple email address.\n\nNo attempt is made to actually parse the address line, or validate that\nit is actually an email address. Implementing such validation is not\ntrivial. Besides, we weren't validating the address between angle\nbrackets before anyways.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n builtin/check-mailmap.c             | 18 +++++++++-------\n Documentation/git-check-mailmap.txt |  8 +++----\n t/t4203-mailmap.sh                  | 42 +++++++++++++++++++++++++++++++++----\n 3 files changed, 53 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c\nindex b8a05b8e07b5..6b7fb53494f0 100644\n--- a/builtin/check-mailmap.c\n+++ b/builtin/check-mailmap.c\n@@ -25,13 +25,17 @@ static void check_mailmap(struct string_list *mailmap, const char *contact)\n \tsize_t namelen, maillen;\n \tstruct ident_split ident;\n \n-\tif (split_ident_line(&ident, contact, strlen(contact)))\n-\t\tdie(_(\"unable to parse contact: %s\"), contact);\n-\n-\tname = ident.name_begin;\n-\tnamelen = ident.name_end - ident.name_begin;\n-\tmail = ident.mail_begin;\n-\tmaillen = ident.mail_end - ident.mail_begin;\n+\tif (!split_ident_line(&ident, contact, strlen(contact))) {\n+\t\tname = ident.name_begin;\n+\t\tnamelen = ident.name_end - ident.name_begin;\n+\t\tmail = ident.mail_begin;\n+\t\tmaillen = ident.mail_end - ident.mail_begin;\n+\t} else {\n+\t\tname = NULL;\n+\t\tnamelen = 0;\n+\t\tmail = contact;\n+\t\tmaillen = strlen(contact);\n+\t}\n \n \tmap_user(mailmap, &mail, &maillen, &name, &namelen);\n \ndiff --git a/Documentation/git-check-mailmap.txt b/Documentation/git-check-mailmap.txt\nindex 02f441832321..7747e38e25e3 100644\n--- a/Documentation/git-check-mailmap.txt\n+++ b/Documentation/git-check-mailmap.txt\n@@ -15,10 +15,10 @@ SYNOPSIS\n DESCRIPTION\n -----------\n \n-For each ``Name $$<user@host>$$'' or ``$$<user@host>$$'' from the command-line\n-or standard input (when using `--stdin`), look up the person's canonical name\n-and email address (see \"Mapping Authors\" below). If found, print them;\n-otherwise print the input as-is.\n+For each ``Name $$<user@host>$$'', ``$$<user@host>$$'', or ``$$user@host$$''\n+from the command-line or standard input (when using `--stdin`), look up the\n+person's canonical name and email address (see \"Mapping Authors\" below). If\n+found, print them; otherwise print the input as-is.\n \n \n OPTIONS\ndiff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh\nindex 79e5f42760d9..2265ff8872df 100755\n--- a/t/t4203-mailmap.sh\n+++ b/t/t4203-mailmap.sh\n@@ -72,12 +72,46 @@ test_expect_success 'check-mailmap --stdin arguments: mapping' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'check-mailmap bogus contact' '\n-\ttest_must_fail git check-mailmap bogus\n+test_expect_success 'check-mailmap simple address: mapping' '\n+\ttest_when_finished \"rm .mailmap\" &&\n+\tcat >.mailmap <<-EOF &&\n+\tNew Name <$GIT_AUTHOR_EMAIL>\n+\tEOF\n+\tcat .mailmap >expect &&\n+\tgit check-mailmap \"$GIT_AUTHOR_EMAIL\" >actual &&\n+\ttest_cmp expect actual\n '\n \n-test_expect_success 'check-mailmap bogus contact --stdin' '\n-\ttest_must_fail git check-mailmap --stdin bogus </dev/null\n+test_expect_success 'check-mailmap --stdin simple address: mapping' '\n+\ttest_when_finished \"rm .mailmap\" &&\n+\tcat >.mailmap <<-EOF &&\n+\tNew Name <$GIT_AUTHOR_EMAIL>\n+\tEOF\n+\tcat >stdin <<-EOF &&\n+\t$GIT_AUTHOR_EMAIL\n+\tEOF\n+\tcat .mailmap >expect &&\n+\tgit check-mailmap --stdin <stdin >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'check-mailmap simple address: no mapping' '\n+\tcat >expect <<-EOF &&\n+\t<bugs@company.xx>\n+\tEOF\n+\tgit check-mailmap \"bugs@company.xx\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success 'check-mailmap --stdin simple address: no mapping' '\n+\tcat >expect <<-EOF &&\n+\t<bugs@company.xx>\n+\tEOF\n+\tcat >stdin <<-EOF &&\n+\tbugs@company.xx\n+\tEOF\n+\tgit check-mailmap --stdin <stdin >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success 'No mailmap' '\n\n-- \n2.46.0.124.g2dc1a81c8933\n\n"},{"id":"501738","messageId":"20240827-jk-send-email-mailmap-support-v3-2-bec5ba9be391@gmail.com","threadId":"62011","inReplyTo":"20240827-jk-send-email-mailmap-support-v3-0-bec5ba9be391@gmail.com","subject":"[PATCH v3 2/3] check-mailmap: add options for additional mailmap sources","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2024-08-27T21:27:17Z","receivedAt":"2024-08-27T21:27:35Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\nThe git check-mailmap command reads the mailmap from either the default\n.mailmap location and then from the mailmap.blob and mailmap.file\nconfigurations.\n\nA following change to git send-email will want to support new\nconfiguration options based on the configured identity. The\nidentity-based configuration and options only make sense in the context\nof git send-email.\n\nExpose the read_mailmap_file and read_mailmap_blob functions from\nmailmap.c.  Teach git check-mailmap the --mailmap-file and\n--mailmap-blob options which load the additional mailmap sources.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n mailmap.h                           |  7 +++++++\n builtin/check-mailmap.c             |  7 +++++++\n mailmap.c                           |  9 +++------\n Documentation/git-check-mailmap.txt | 10 ++++++++++\n 4 files changed, 27 insertions(+), 6 deletions(-)\n\ndiff --git a/mailmap.h b/mailmap.h\nindex cbda9bc5e0c1..908365e1bffa 100644\n--- a/mailmap.h\n+++ b/mailmap.h\n@@ -6,6 +6,13 @@ struct string_list;\n extern char *git_mailmap_file;\n extern char *git_mailmap_blob;\n \n+/* Flags for read_mailmap_file() */\n+#define MAILMAP_NOFOLLOW (1<<0)\n+\n+int read_mailmap_file(struct string_list *map, const char *filename,\n+\t\t      unsigned flags);\n+int read_mailmap_blob(struct string_list *map, const char *name);\n+\n int read_mailmap(struct string_list *map);\n void clear_mailmap(struct string_list *map);\n \ndiff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c\nindex 6b7fb53494f0..2334b5722275 100644\n--- a/builtin/check-mailmap.c\n+++ b/builtin/check-mailmap.c\n@@ -9,6 +9,7 @@\n #include \"write-or-die.h\"\n \n static int use_stdin;\n+static const char *mailmap_file, *mailmap_blob;\n static const char * const check_mailmap_usage[] = {\n N_(\"git check-mailmap [<options>] <contact>...\"),\n NULL\n@@ -16,6 +17,8 @@ NULL\n \n static const struct option check_mailmap_options[] = {\n \tOPT_BOOL(0, \"stdin\", &use_stdin, N_(\"also read contacts from stdin\")),\n+\tOPT_FILENAME(0, \"mailmap-file\", &mailmap_file, N_(\"read additional mailmap entries from file\")),\n+\tOPT_STRING(0, \"mailmap-blob\", &mailmap_blob, N_(\"blob\"), N_(\"read additional mailmap entries from blob\")),\n \tOPT_END()\n };\n \n@@ -56,6 +59,10 @@ int cmd_check_mailmap(int argc, const char **argv, const char *prefix)\n \t\tdie(_(\"no contacts specified\"));\n \n \tread_mailmap(&mailmap);\n+\tif (mailmap_blob)\n+\t\tread_mailmap_blob(&mailmap, mailmap_blob);\n+\tif (mailmap_file)\n+\t\tread_mailmap_file(&mailmap, mailmap_file, 0);\n \n \tfor (i = 0; i < argc; ++i)\n \t\tcheck_mailmap(&mailmap, argv[i]);\ndiff --git a/mailmap.c b/mailmap.c\nindex 2acf97f30760..9f9fa3199a85 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -142,11 +142,8 @@ static void read_mailmap_line(struct string_list *map, char *buffer)\n \t\tadd_mapping(map, name1, email1, name2, email2);\n }\n \n-/* Flags for read_mailmap_file() */\n-#define MAILMAP_NOFOLLOW (1<<0)\n-\n-static int read_mailmap_file(struct string_list *map, const char *filename,\n-\t\t\t     unsigned flags)\n+int read_mailmap_file(struct string_list *map, const char *filename,\n+\t\t      unsigned flags)\n {\n \tchar buffer[1024];\n \tFILE *f;\n@@ -186,7 +183,7 @@ static void read_mailmap_string(struct string_list *map, char *buf)\n \t}\n }\n \n-static int read_mailmap_blob(struct string_list *map, const char *name)\n+int read_mailmap_blob(struct string_list *map, const char *name)\n {\n \tstruct object_id oid;\n \tchar *buf;\ndiff --git a/Documentation/git-check-mailmap.txt b/Documentation/git-check-mailmap.txt\nindex 7747e38e25e3..966c91c46af7 100644\n--- a/Documentation/git-check-mailmap.txt\n+++ b/Documentation/git-check-mailmap.txt\n@@ -27,6 +27,16 @@ OPTIONS\n \tRead contacts, one per line, from the standard input after exhausting\n \tcontacts provided on the command-line.\n \n+--mailmap-file=<file>::\n+\tIn addition to any configured mailmap files, read the specified\n+\tmailmap file. Entries in this file take precedence over entries in\n+\teither the default mailmap file or any configured mailmap file.\n+\n+--mailmap-blob=<blob>::\n+\tLike `--mailmap-file`, but consider the value as a reference to a\n+\tblob in the repository. If both `--mailmap-file` and\n+\t`--mailmap-blob` are specified, entries in `--mailmap-file` will\n+\ttake precedence.\n \n OUTPUT\n ------\n\n-- \n2.46.0.124.g2dc1a81c8933\n\n"},{"id":"501739","messageId":"20240827-jk-send-email-mailmap-support-v3-3-bec5ba9be391@gmail.com","threadId":"62011","inReplyTo":"20240827-jk-send-email-mailmap-support-v3-0-bec5ba9be391@gmail.com","subject":"[PATCH v3 3/3] send-email: add mailmap support via sendemail.mailmap and --mailmap","fromName":"Jacob Keller","fromEmail":"jacob.e.keller@intel.com","sentAt":"2024-08-27T21:27:18Z","receivedAt":"2024-08-27T21:27:37Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"From: Jacob Keller <jacob.keller@gmail.com>\n\nIn some cases, a user may be generating a patch for an old commit which\nnow has an out-of-date author or other identity. For example, consider a\nteam member who contributes to an internal fork of an upstream project,\nbut leaves before this change is submitted upstream.\n\nIn this case, the team members company address may no longer be valid,\nand will thus bounce when sending email.\n\nThis can be manually avoided by editing the generated patch files, or by\ncarefully using --suppress-<cc|to> options. This requires a lot of\nmanual intervention and is easy to forget.\n\nGit has support for mapping old email addresses and names to a canonical\nname and address via the .mailmap file (and its associated mailmap.file,\nmailmap.blob, and log.mailmap options).\n\nTeach git send-email to enable mailmap support for all addresses. This\nensures that addresses point to the canonical real name and email\naddress.\n\nAdd the sendemail.mailmap configuration option and its associated\n--mailmap (and --use-mailmap for compatibility with git log) options.\nFor now, the default behavior is to disable the mailmap in order to\navoid any surprises or breaking any existing setups.\n\nThese options support per-identity configuration via the\nsendemail.identity configuration blocks. This enables identity-specific\nconfiguration in cases where users may not want to enable support.\n\nIn addition, support send-email specific mailmap data via\nsendemail.mailmap.file, sendemail.mailmap.blob and their\nidentity-specific variants.\n\nThe intention of these options is to enable mapping addresses which are\nno longer valid to a current project or team maintainer. Such mappings\nmay change the actual person being referred to, and may not make sense\nin a traditional mailmap file which is intended for updating canonical\nname and address for the same individual.\n\nSigned-off-by: Jacob Keller <jacob.keller@gmail.com>\n---\n git-send-email.perl   |  20 +++++++++\n t/t9001-send-email.sh | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 142 insertions(+)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 72044e5ef3a8..8995d5f12d9e 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -46,6 +46,8 @@ sub usage {\n     --compose-encoding      <str>  * Encoding to assume for introduction.\n     --8bit-encoding         <str>  * Encoding to assume 8bit mails if undeclared\n     --transfer-encoding     <str>  * Transfer encoding to use (quoted-printable, 8bit, base64)\n+    --[no-]mailmap                 * Use mailmap file to map all email addresses to canonical\n+                                     real names and email addresses.\n \n   Sending:\n     --envelope-sender       <str>  * Email envelope sender.\n@@ -272,12 +274,14 @@ sub do_edit {\n my ($auto_8bit_encoding);\n my ($compose_encoding);\n my ($sendmail_cmd);\n+my ($mailmap_file, $mailmap_blob);\n # Variables with corresponding config settings & hardcoded defaults\n my ($debug_net_smtp) = 0;\t\t# Net::SMTP, see send_message()\n my $thread = 1;\n my $chain_reply_to = 0;\n my $use_xmailer = 1;\n my $validate = 1;\n+my $mailmap = 0;\n my $target_xfer_encoding = 'auto';\n my $forbid_sendmail_variables = 1;\n \n@@ -294,6 +298,7 @@ sub do_edit {\n     \"annotate\" => \\$annotate,\n     \"xmailer\" => \\$use_xmailer,\n     \"forbidsendmailvariables\" => \\$forbid_sendmail_variables,\n+    \"mailmap\" => \\$mailmap,\n );\n \n my %config_settings = (\n@@ -327,6 +332,8 @@ sub do_edit {\n my %config_path_settings = (\n     \"aliasesfile\" => \\@alias_files,\n     \"smtpsslcertpath\" => \\$smtp_ssl_cert_path,\n+    \"mailmap.file\" => \\$mailmap_file,\n+    \"mailmap.blob\" => \\$mailmap_blob,\n );\n \n # Handle Uncouth Termination\n@@ -524,6 +531,8 @@ sub config_regexp {\n \t\t    \"thread!\" => \\$thread,\n \t\t    \"validate!\" => \\$validate,\n \t\t    \"transfer-encoding=s\" => \\$target_xfer_encoding,\n+\t\t    \"mailmap!\" => \\$mailmap,\n+\t\t    \"use-mailmap!\" => \\$mailmap,\n \t\t    \"format-patch!\" => \\$format_patch,\n \t\t    \"8bit-encoding=s\" => \\$auto_8bit_encoding,\n \t\t    \"compose-encoding=s\" => \\$compose_encoding,\n@@ -1085,6 +1094,16 @@ sub expand_one_alias {\n our ($message_id, %mail, $subject, $in_reply_to, $references, $message,\n \t$needs_confirm, $message_num, $ask_default);\n \n+sub mailmap_address_list {\n+\treturn @_ unless @_ and $mailmap;\n+\tmy @options = ();\n+\tpush(@options, \"--mailmap-file=$mailmap_file\") if $mailmap_file;\n+\tpush(@options, \"--mailmap-blob=$mailmap_blob\") if $mailmap_blob;\n+\tmy @addr_list = Git::command('check-mailmap', @options, @_);\n+\ts/^<(.*)>$/$1/ for @addr_list;\n+\treturn @addr_list;\n+}\n+\n sub extract_valid_address {\n \tmy $address = shift;\n \tmy $local_part_regexp = qr/[^<>\"\\s@]+/;\n@@ -1294,6 +1313,7 @@ sub process_address_list {\n \t@addr_list = expand_aliases(@addr_list);\n \t@addr_list = sanitize_address_list(@addr_list);\n \t@addr_list = validate_address_list(@addr_list);\n+\t@addr_list = mailmap_address_list(@addr_list);\n \treturn @addr_list;\n }\n \ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 64a4ab3736ef..4bdc793a53a2 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -2379,6 +2379,128 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '\n \ttest_cmp expected-list actual-list\n '\n \n+test_expect_success $PREREQ 'mailmap support with --to' '\n+\tclean_fake_sendmail &&\n+\ttest_config mailmap.file \"mailmap.test\" &&\n+\tcat >mailmap.test <<-EOF &&\n+\tSome Body <someone@example.com> <someone@example.org>\n+\tEOF\n+\tgit format-patch --stdout -1 >a.patch &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--to=someone@example.org \\\n+\t\t--mailmap \\\n+\t\ta.patch \\\n+\t\t2>errors >out &&\n+\tgrep \"^!someone@example\\.com!$\" commandline1\n+'\n+\n+test_expect_success $PREREQ 'sendemail.mailmap configuration' '\n+\tclean_fake_sendmail &&\n+\ttest_config mailmap.file \"mailmap.test\" &&\n+\ttest_config sendemail.mailmap \"true\" &&\n+\tcat >mailmap.test <<-EOF &&\n+\tSome Body <someone@example.com> <someone@example.org>\n+\tEOF\n+\tgit format-patch --stdout -1 >a.patch &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--to=someone@example.org \\\n+\t\ta.patch \\\n+\t\t2>errors >out &&\n+\tgrep \"^!someone@example\\.com!$\" commandline1\n+'\n+\n+test_expect_success $PREREQ 'sendemail.mailmap.file configuration' '\n+\tclean_fake_sendmail &&\n+\ttest_config sendemail.mailmap.file \"mailmap.test\" &&\n+\ttest_config sendemail.mailmap \"true\" &&\n+\tcat >mailmap.test <<-EOF &&\n+\tSome Body <someone@example.com> <someone@example.org>\n+\tEOF\n+\tgit format-patch --stdout -1 >a.patch &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--to=someone@example.org \\\n+\t\ta.patch \\\n+\t\t2>errors >out &&\n+\tgrep \"^!someone@example\\.com!$\" commandline1\n+'\n+\n+test_expect_success $PREREQ 'sendemail.mailmap identity overrides configuration' '\n+\tclean_fake_sendmail &&\n+\ttest_config sendemail.cloud.mailmap.file \"mailmap.test\" &&\n+\ttest_config sendemail.mailmap \"false\" &&\n+\ttest_config sendemail.cloud.mailmap \"true\" &&\n+\tcat >mailmap.test <<-EOF &&\n+\tSome Body <someone@example.com> <someone@example.org>\n+\tEOF\n+\tgit format-patch --stdout -1 >a.patch &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--identity=cloud \\\n+\t\t--to=someone@example.org \\\n+\t\ta.patch \\\n+\t\t2>errors >out &&\n+\tgrep \"^!someone@example\\.com!$\" commandline1\n+'\n+\n+test_expect_success $PREREQ '--no-mailmap overrides configuration' '\n+\tclean_fake_sendmail &&\n+\ttest_config sendemail.cloud.mailmap.file \"mailmap.test\" &&\n+\ttest_config sendemail.mailmap \"false\" &&\n+\ttest_config sendemail.cloud.mailmap \"true\" &&\n+\tcat >mailmap.test <<-EOF &&\n+\tSome Body <someone@example.com> <someone@example.org>\n+\tEOF\n+\tgit format-patch --stdout -1 >a.patch &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--identity=cloud \\\n+\t\t--to=someone@example.org \\\n+\t\t--no-mailmap \\\n+\t\ta.patch \\\n+\t\t2>errors >out &&\n+\tgrep \"^!someone@example\\.org!$\" commandline1\n+'\n+\n+test_expect_success $PREREQ 'mailmap support in To header' '\n+\tclean_fake_sendmail &&\n+\ttest_config mailmap.file \"mailmap.test\" &&\n+\tcat >mailmap.test <<-EOF &&\n+\t<someone@example.com> <someone@example.org>\n+\tEOF\n+\tgit format-patch --stdout -1 --to=someone@example.org >a.patch &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--mailmap \\\n+\t\ta.patch \\\n+\t\t2>errors >out &&\n+\tgrep \"^!someone@example\\.com!$\" commandline1\n+'\n+\n+test_expect_success $PREREQ 'mailmap support in Cc header' '\n+\tclean_fake_sendmail &&\n+\ttest_config mailmap.file \"mailmap.test\" &&\n+\tcat >mailmap.test <<-EOF &&\n+\t<someone@example.com> <someone@example.org>\n+\tEOF\n+\tgit format-patch --stdout -1 --cc=someone@example.org >a.patch &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--mailmap \\\n+\t\ta.patch \\\n+\t\t2>errors >out &&\n+\tgrep \"^!someone@example\\.com!$\" commandline1\n+'\n+\n test_expect_success $PREREQ 'test using command name with --sendmail-cmd' '\n \tclean_fake_sendmail &&\n \tPATH=\"$PWD:$PATH\" \\\n\n-- \n2.46.0.124.g2dc1a81c8933\n\n"},{"id":"501743","messageId":"xmqqjzg15s3r.fsf@gitster.g","threadId":"62011","inReplyTo":"20240827-jk-send-email-mailmap-support-v3-0-bec5ba9be391@gmail.com","subject":"Re: [PATCH v3 0/3] send-email: add --mailmap support","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-08-28T01:55:04Z","receivedAt":"2024-08-28T01:55:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jacob Keller <jacob.e.keller@intel.com> writes:\n\n> Changes in v3:\n> - Edit description of patch 1 to clarify lack of validation of email\n>   addresses.\n> - Update tests for check-mailmap, removing the bogus contact tests entirely.\n> - Link to v2: https://lore.kernel.org/r/20240819-jk-send-email-mailmap-support-v2-0-d212c3f9e505@gmail.com\n\nAll the incremental changes looked sensible to me.  Let me wait for\na few days and then mark the topic for 'next', unless others find\nissues.\n\nThanks.\n"},{"id":"501793","messageId":"yj7at3g36nr2c5gr4bywp5vnvbt7bkel5e7l2boakua5hez2au@pc2f4o5ahmpm","threadId":"62011","inReplyTo":"20240827-jk-send-email-mailmap-support-v3-0-bec5ba9be391@gmail.com","subject":"Re: [PATCH v3 0/3] send-email: add --mailmap support","fromName":"Josh Steadmon","fromEmail":"steadmon@google.com","sentAt":"2024-08-28T21:23:40Z","receivedAt":"2024-08-28T21:23:47Z","isPatch":true,"sender":{"key":"steadmon@google.com","avatar":"https://avatars.githubusercontent.com/u/2654920?v=4"},"body":"On 2024.08.27 14:27, Jacob Keller wrote:\n> I recently sent a series to enable mailmap support in format patch. The\n> discussion led me to realize that the true problem we wanted solved is to\n> map addresses at send time, so that we do not accidentally include a dead\n> mail address when sending an old change.\n> \n> Instead of worrying about what the formatted patch has, this series\n> implements support for mailmap at the send-email, which will translate all\n> addresses, and not just the author/commit addresses for a patch, but also\n> the email for any trailers.o\n> \n> Since v2, we now have a configuration option (sendemail.mailmap) to enable\n> this behavior. In addition, I enabled support for email-specific mailmap\n> files.\n> \n> The intention of these is to allow a maintainer to map the known-dead\n> addresses of former colleagues onto a current email for an owner within the\n> team. This would be used to update the send addresses to avoid including\n> no-longer-valid addresses when sending patches. This is intended for cases\n> where the original author is no longer valid such as when they are no\n> longer employed to work on the project. While sometimes pointing to a\n> canonical public address of that person may make sense, in other contexts,\n> removing them from the email makes sense.\n> \n> I believe this version solves the use case we have of ensuring that we stop\n> sending emails with invalid addresses, and may be useful for others as\n> well.\n> \n> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>\n> ---\n> Changes in v3:\n> - Edit description of patch 1 to clarify lack of validation of email\n>   addresses.\n> - Update tests for check-mailmap, removing the bogus contact tests entirely.\n> - Link to v2: https://lore.kernel.org/r/20240819-jk-send-email-mailmap-support-v2-0-d212c3f9e505@gmail.com\n> \n> Changes in v2:\n> - Loosen restriction on git check-mailmap by default, rather than\n>   introducing a specific --no-brackets option.\n> - Re-write commit message for the send-email changes.\n> - Add --mailmap-file and --mailmap-blob options to git check-mailmap.\n> - Add configuration options to git send-email for enabling mailmap support\n>   by default, as well as providing send-email specific mailmap files.\n> - Link to v1: https://lore.kernel.org/r/20240816-jk-send-email-mailmap-support-v1-0-68ca5b4a6078@gmail.com\n> - Link to previous \"v0\": https://lore.kernel.org/r/20240813-jk-support-mailmap-git-format-patch-v1-1-1aea690ea5dd@gmail.com\n> \n> ---\n> Jacob Keller (3):\n>       check-mailmap: accept \"user@host\" contacts\n>       check-mailmap: add options for additional mailmap sources\n>       send-email: add mailmap support via sendemail.mailmap and --mailmap\n> \n>  mailmap.h                           |   7 +++\n>  builtin/check-mailmap.c             |  25 +++++---\n>  mailmap.c                           |   9 +--\n>  Documentation/git-check-mailmap.txt |  18 ++++--\n>  git-send-email.perl                 |  20 ++++++\n>  t/t4203-mailmap.sh                  |  42 +++++++++++--\n>  t/t9001-send-email.sh               | 122 ++++++++++++++++++++++++++++++++++++\n>  7 files changed, 222 insertions(+), 21 deletions(-)\n> ---\n> base-commit: 87a1768b93a67d0420255a43d9e07387b2e805ad\n> change-id: 20240816-jk-send-email-mailmap-support-1a9e86867c72\n> \n> Best regards,\n> -- \n> Jacob Keller <jacob.keller@gmail.com>\n> \n\nI'm not sure I'm competent enough with perl to review part of patch 3,\nbut other than that everything looks good to me. Thanks for the series!\n\nReviewed-by: Josh Steadmon <steadmon@google.com>\n"}]}