{"thread":{"id":"47973","subject":"git-send-email: Support for Reply-To","startedAt":"2018-03-03T23:58:57Z","lastAt":"2018-03-06T08:07:05Z","messageCount":4,"participants":["Christian Ludwig","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"340962","messageId":"20180303235814.7241-1-chrissicool@gmail.com","threadId":"47973","inReplyTo":null,"subject":"git-send-email: Support for Reply-To","fromName":"Christian Ludwig","fromEmail":"chrissicool@gmail.com","sentAt":"2018-03-03T23:58:12Z","receivedAt":"2018-03-03T23:58:57Z","isPatch":false,"sender":{"key":"chrissicool@gmail.com","avatar":"https://avatars.githubusercontent.com/u/232590?v=4"},"body":"Hi,\n\nthis is the third iteration of this series. There was a request to\nrebase the changes on the refactoring patch b6049542 (\"send-email:\nextract email-parsing code into a subroutine\", 2017-12-15). This is\nthe result.\n\nThe diffstat is the same compared to the last revision. It could be\nmade smaller by sacrificing readibility and breaking the scheme\nintroduced by the refactoring patch. But I do agree that send-email's\nreadability could benefit from slicing it into handy functions. And the\nrefactoring patch reduces the nesting of loops/conditionals.\n\nBut it's your code, you decide. I can re-send a fixed-up v2 without the\nrebasing.\n\n\nSo long,\n\n\n - Christian\n"},{"id":"340963","messageId":"20180303235814.7241-2-chrissicool@gmail.com","threadId":"47973","inReplyTo":"20180303235814.7241-1-chrissicool@gmail.com","subject":"[PATCH v3 1/2] send-email: Rename variable for clarity","fromName":"Christian Ludwig","fromEmail":"chrissicool@gmail.com","sentAt":"2018-03-03T23:58:13Z","receivedAt":"2018-03-03T23:58:59Z","isPatch":true,"sender":{"key":"chrissicool@gmail.com","avatar":"https://avatars.githubusercontent.com/u/232590?v=4"},"body":"The SMTP protocol has both, the 'Reply-To' and the 'In-Reply-To' header\nfields. We only use the latter. To avoid confusion, rename the variable\nfor it.\n\nSigned-off-by: Christian Ludwig <chrissicool@gmail.com>\n---\n git-send-email.perl | 38 +++++++++++++++++++-------------------\n 1 file changed, 19 insertions(+), 19 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex d0dcc6d7f..9eb12b5ba 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -167,13 +167,13 @@ my $re_encoded_word = qr/=\\?($re_token)\\?($re_token)\\?($re_encoded_text)\\?=/;\n \n # Variables we fill in automatically, or via prompting:\n my (@to,$no_to,@initial_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh,\n-\t$initial_reply_to,$initial_subject,@files,\n+\t$initial_in_reply_to,$initial_subject,@files,\n \t$author,$sender,$smtp_authpass,$annotate,$use_xmailer,$compose,$time);\n \n my $envelope_sender;\n \n # Example reply to:\n-#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';\n+#$initial_in_reply_to = ''; #<20050203173208.GA23964@foobar.com>';\n \n my $repo = eval { Git->repository() };\n my @repo = $repo ? ($repo) : ();\n@@ -315,7 +315,7 @@ die __(\"--dump-aliases incompatible with other options\\n\")\n     if !$help and $dump_aliases and @ARGV;\n $rc = GetOptions(\n \t\t    \"sender|from=s\" => \\$sender,\n-                    \"in-reply-to=s\" => \\$initial_reply_to,\n+                    \"in-reply-to=s\" => \\$initial_in_reply_to,\n \t\t    \"subject=s\" => \\$initial_subject,\n \t\t    \"to=s\" => \\@initial_to,\n \t\t    \"to-cmd=s\" => \\$to_cmd,\n@@ -677,7 +677,7 @@ if ($compose) {\n \n \tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n \tmy $tpl_subject = $initial_subject || '';\n-\tmy $tpl_reply_to = $initial_reply_to || '';\n+\tmy $tpl_in_reply_to = $initial_in_reply_to || '';\n \n \tprint $c <<EOT1, Git::prefix_lines(\"GIT: \", __ <<EOT2), <<EOT3;\n From $tpl_sender # This line is ignored.\n@@ -690,7 +690,7 @@ Clear the body content if you don't wish to send a summary.\n EOT2\n From: $tpl_sender\n Subject: $tpl_subject\n-In-Reply-To: $tpl_reply_to\n+In-Reply-To: $tpl_in_reply_to\n \n EOT3\n \tfor my $f (@files) {\n@@ -729,7 +729,7 @@ EOT3\n \t\t$sender = delete($parsed_email{'From'});\n \t}\n \tif ($parsed_email{'In-Reply-To'}) {\n-\t\t$initial_reply_to = delete($parsed_email{'In-Reply-To'});\n+\t\t$initial_in_reply_to = delete($parsed_email{'In-Reply-To'});\n \t}\n \tif ($parsed_email{'Subject'}) {\n \t\t$initial_subject = delete($parsed_email{'Subject'});\n@@ -912,16 +912,16 @@ sub expand_one_alias {\n @initial_cc = process_address_list(@initial_cc);\n @bcclist = process_address_list(@bcclist);\n \n-if ($thread && !defined $initial_reply_to && $prompting) {\n-\t$initial_reply_to = ask(\n+if ($thread && !defined $initial_in_reply_to && $prompting) {\n+\t$initial_in_reply_to = ask(\n \t\t__(\"Message-ID to be used as In-Reply-To for the first email (if any)? \"),\n \t\tdefault => \"\",\n \t\tvalid_re => qr/\\@.*\\./, confirm_only => 1);\n }\n-if (defined $initial_reply_to) {\n-\t$initial_reply_to =~ s/^\\s*<?//;\n-\t$initial_reply_to =~ s/>?\\s*$//;\n-\t$initial_reply_to = \"<$initial_reply_to>\" if $initial_reply_to ne '';\n+if (defined $initial_in_reply_to) {\n+\t$initial_in_reply_to =~ s/^\\s*<?//;\n+\t$initial_in_reply_to =~ s/>?\\s*$//;\n+\t$initial_in_reply_to = \"<$initial_in_reply_to>\" if $initial_in_reply_to ne '';\n }\n \n if (!defined $smtp_server) {\n@@ -941,7 +941,7 @@ if ($compose && $compose > 0) {\n }\n \n # Variables we set as part of the loop over files\n-our ($message_id, %mail, $subject, $reply_to, $references, $message,\n+our ($message_id, %mail, $subject, $in_reply_to, $references, $message,\n \t$needs_confirm, $message_num, $ask_default);\n \n sub extract_valid_address {\n@@ -1350,9 +1350,9 @@ Message-Id: $message_id\n \tif ($use_xmailer) {\n \t\t$header .= \"X-Mailer: git-send-email $gitversion\\n\";\n \t}\n-\tif ($reply_to) {\n+\tif ($in_reply_to) {\n \n-\t\t$header .= \"In-Reply-To: $reply_to\\n\";\n+\t\t$header .= \"In-Reply-To: $in_reply_to\\n\";\n \t\t$header .= \"References: $references\\n\";\n \t}\n \tif (@xh) {\n@@ -1529,8 +1529,8 @@ EOF\n \treturn 1;\n }\n \n-$reply_to = $initial_reply_to;\n-$references = $initial_reply_to || '';\n+$in_reply_to = $initial_in_reply_to;\n+$references = $initial_in_reply_to || '';\n $subject = $initial_subject;\n $message_num = 0;\n \n@@ -1740,9 +1740,9 @@ foreach my $t (@files) {\n \n \t# set up for the next message\n \tif ($thread && $message_was_sent &&\n-\t\t($chain_reply_to || !defined $reply_to || length($reply_to) == 0 ||\n+\t\t($chain_reply_to || !defined $in_reply_to || length($in_reply_to) == 0 ||\n \t\t$message_num == 1)) {\n-\t\t$reply_to = $message_id;\n+\t\t$in_reply_to = $message_id;\n \t\tif (length $references > 0) {\n \t\t\t$references .= \"\\n $message_id\";\n \t\t} else {\n-- \n2.16.2\n\n"},{"id":"340964","messageId":"20180303235814.7241-3-chrissicool@gmail.com","threadId":"47973","inReplyTo":"20180303235814.7241-1-chrissicool@gmail.com","subject":"[PATCH v3 2/2] send-email: Support separate Reply-To address","fromName":"Christian Ludwig","fromEmail":"chrissicool@gmail.com","sentAt":"2018-03-03T23:58:14Z","receivedAt":"2018-03-03T23:59:02Z","isPatch":true,"sender":{"key":"chrissicool@gmail.com","avatar":"https://avatars.githubusercontent.com/u/232590?v=4"},"body":"In some projects contributions from groups are only accepted from a\ncommon group email address. But every individual may want to receive\nreplies to her own personal address. That's what we have 'Reply-To'\nheaders for in SMTP. So introduce an optional '--reply-to' command\nline option.\n\nThis patch re-uses the $reply_to variable. This could break\nout-of-tree patches!\n\nSigned-off-by: Christian Ludwig <chrissicool@gmail.com>\n---\n Documentation/git-send-email.txt       |  5 +++++\n contrib/completion/git-completion.bash |  2 +-\n git-send-email.perl                    | 18 +++++++++++++++++-\n t/t9001-send-email.sh                  |  2 ++\n 4 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 8060ea35c..71ef97ba9 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -84,6 +84,11 @@ See the CONFIGURATION section for `sendemail.multiEdit`.\n \tthe value of GIT_AUTHOR_IDENT, or GIT_COMMITTER_IDENT if that is not\n \tset, as returned by \"git var -l\".\n \n+--reply-to=<address>::\n+\tSpecify the address where replies from recipients should go to.\n+\tUse this if replies to messages should go to another address than what\n+\tis specified with the --from parameter.\n+\n --in-reply-to=<identifier>::\n \tMake the first mail (or all the mails with `--no-thread`) appear as a\n \treply to the given Message-Id, which avoids breaking threads to\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex c7d5c7af2..4805b92ba 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2081,7 +2081,7 @@ _git_send_email ()\n \t\t\t--compose --confirm= --dry-run --envelope-sender\n \t\t\t--from --identity\n \t\t\t--in-reply-to --no-chain-reply-to --no-signed-off-by-cc\n-\t\t\t--no-suppress-from --no-thread --quiet\n+\t\t\t--no-suppress-from --no-thread --quiet --reply-to\n \t\t\t--signed-off-by-cc --smtp-pass --smtp-server\n \t\t\t--smtp-server-port --smtp-encryption= --smtp-user\n \t\t\t--subject --suppress-cc= --suppress-from --thread --to\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 9eb12b5ba..707ec9eb7 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -57,6 +57,7 @@ git send-email --dump-aliases\n     --[no-]cc               <str>  * Email Cc:\n     --[no-]bcc              <str>  * Email Bcc:\n     --subject               <str>  * Email \"Subject:\"\n+    --reply-to              <str>  * Email \"Reply-To:\"\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n     --[no-]xmailer                 * Add \"X-Mailer:\" header (default).\n     --[no-]annotate                * Review each patch that will be sent in an editor.\n@@ -167,7 +168,7 @@ my $re_encoded_word = qr/=\\?($re_token)\\?($re_token)\\?($re_encoded_text)\\?=/;\n \n # Variables we fill in automatically, or via prompting:\n my (@to,$no_to,@initial_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh,\n-\t$initial_in_reply_to,$initial_subject,@files,\n+\t$initial_in_reply_to,$reply_to,$initial_subject,@files,\n \t$author,$sender,$smtp_authpass,$annotate,$use_xmailer,$compose,$time);\n \n my $envelope_sender;\n@@ -316,6 +317,7 @@ die __(\"--dump-aliases incompatible with other options\\n\")\n $rc = GetOptions(\n \t\t    \"sender|from=s\" => \\$sender,\n                     \"in-reply-to=s\" => \\$initial_in_reply_to,\n+\t\t    \"reply-to=s\" => \\$reply_to,\n \t\t    \"subject=s\" => \\$initial_subject,\n \t\t    \"to=s\" => \\@initial_to,\n \t\t    \"to-cmd=s\" => \\$to_cmd,\n@@ -678,6 +680,7 @@ if ($compose) {\n \tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n \tmy $tpl_subject = $initial_subject || '';\n \tmy $tpl_in_reply_to = $initial_in_reply_to || '';\n+\tmy $tpl_reply_to = $reply_to || '';\n \n \tprint $c <<EOT1, Git::prefix_lines(\"GIT: \", __ <<EOT2), <<EOT3;\n From $tpl_sender # This line is ignored.\n@@ -689,6 +692,7 @@ for the patch you are writing.\n Clear the body content if you don't wish to send a summary.\n EOT2\n From: $tpl_sender\n+Reply-To: $tpl_reply_to\n Subject: $tpl_subject\n In-Reply-To: $tpl_in_reply_to\n \n@@ -731,6 +735,9 @@ EOT3\n \tif ($parsed_email{'In-Reply-To'}) {\n \t\t$initial_in_reply_to = delete($parsed_email{'In-Reply-To'});\n \t}\n+\tif ($parsed_email{'Reply-To'}) {\n+\t\t$reply_to = delete($parsed_email{'Reply-To'});\n+\t}\n \tif ($parsed_email{'Subject'}) {\n \t\t$initial_subject = delete($parsed_email{'Subject'});\n \t\tprint $c2 \"Subject: \" .\n@@ -924,6 +931,12 @@ if (defined $initial_in_reply_to) {\n \t$initial_in_reply_to = \"<$initial_in_reply_to>\" if $initial_in_reply_to ne '';\n }\n \n+if (defined $reply_to) {\n+\t$reply_to =~ s/^\\s+|\\s+$//g;\n+\t($reply_to) = expand_aliases($reply_to);\n+\t$reply_to = sanitize_address($reply_to);\n+}\n+\n if (!defined $smtp_server) {\n \tmy @sendmail_paths = qw( /usr/sbin/sendmail /usr/lib/sendmail );\n \tpush @sendmail_paths, map {\"$_/sendmail\"} split /:/, $ENV{PATH};\n@@ -1355,6 +1368,9 @@ Message-Id: $message_id\n \t\t$header .= \"In-Reply-To: $in_reply_to\\n\";\n \t\t$header .= \"References: $references\\n\";\n \t}\n+\tif ($reply_to) {\n+\t\t$header .= \"Reply-To: $reply_to\\n\";\n+\t}\n \tif (@xh) {\n \t\t$header .= join(\"\\n\", @xh) . \"\\n\";\n \t}\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 19601fb54..e80eacbb1 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -224,6 +224,7 @@ Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n In-Reply-To: <unique-message-id@example.com>\n References: <unique-message-id@example.com>\n+Reply-To: Reply <reply@example.com>\n \n Result: OK\n EOF\n@@ -316,6 +317,7 @@ test_expect_success $PREREQ 'Show all headers' '\n \t\t--dry-run \\\n \t\t--suppress-cc=sob \\\n \t\t--from=\"Example <from@example.com>\" \\\n+\t\t--reply-to=\"Reply <reply@example.com>\" \\\n \t\t--to=to@example.com \\\n \t\t--cc=cc@example.com \\\n \t\t--bcc=bcc@example.com \\\n-- \n2.16.2\n\n"},{"id":"341106","messageId":"xmqq371d7hlp.fsf@gitster-ct.c.googlers.com","threadId":"47973","inReplyTo":"20180303235814.7241-1-chrissicool@gmail.com","subject":"Re: git-send-email: Support for Reply-To","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-03-06T08:06:58Z","receivedAt":"2018-03-06T08:07:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Ludwig <chrissicool@gmail.com> writes:\n\n> this is the third iteration of this series. There was a request to\n> rebase the changes on the refactoring patch b6049542 (\"send-email:\n> extract email-parsing code into a subroutine\", 2017-12-15). This is\n> the result.\n\nThanks.  Let me Cc the party who did the refactoring, as it was\nunclear how much value the change that did only refactoring without\nhaving an actual user of the end result---now we do have code that\nuses it.\n\n> The diffstat is the same compared to the last revision. It could be\n> made smaller by sacrificing readibility and breaking the scheme\n> introduced by the refactoring patch. But I do agree that send-email's\n> readability could benefit from slicing it into handy functions. And the\n> refactoring patch reduces the nesting of loops/conditionals.\n\nThanks.\n\nI compared the result of applying these on top of the refactoring\ncommit, and cherry-picking the previous round on top of the same\nrefactoring commit, and found that they pretty much result in the\nsame code (which was an exercise for me to gain confidence in this\ncode).\n"}]}