@@ -57,6 +57,7 @@ sub usage {
5757 --[no-]cc <str> * Email Cc:
5858 --[no-]bcc <str> * Email Bcc:
5959 --subject <str> * Email "Subject:"
60+ --reply-to <str> * Email "Reply-To:"
6061 --in-reply-to <str> * Email "In-Reply-To:"
6162 --[no-]xmailer * Add "X-Mailer:" header (default).
6263 --[no-]annotate * Review each patch that will be sent in an editor.
@@ -167,13 +168,13 @@ sub format_2822_time {
167168
168169# Variables we fill in automatically, or via prompting:
169170my (@to ,$no_to ,@initial_to ,@cc ,$no_cc ,@initial_cc ,@bcclist ,$no_bcc ,@xh ,
170- $initial_reply_to ,$initial_subject ,@files ,
171+ $initial_in_reply_to , $reply_to ,$initial_subject ,@files ,
171172 $author ,$sender ,$smtp_authpass ,$annotate ,$use_xmailer ,$compose ,$time );
172173
173174my $envelope_sender ;
174175
175176# Example reply to:
176- # $initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
177+ # $initial_in_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
177178
178179my $repo = eval { Git-> repository() };
179180my @repo = $repo ? ($repo ) : ();
@@ -315,7 +316,8 @@ sub signal_handler {
315316 if !$help and $dump_aliases and @ARGV ;
316317$rc = GetOptions(
317318 " sender|from=s" => \$sender ,
318- " in-reply-to=s" => \$initial_reply_to ,
319+ " in-reply-to=s" => \$initial_in_reply_to ,
320+ " reply-to=s" => \$reply_to ,
319321 " subject=s" => \$initial_subject ,
320322 " to=s" => \@initial_to ,
321323 " to-cmd=s" => \$to_cmd ,
@@ -681,7 +683,8 @@ sub get_patch_subject {
681683
682684 my $tpl_sender = $sender || $repoauthor || $repocommitter || ' ' ;
683685 my $tpl_subject = $initial_subject || ' ' ;
684- my $tpl_reply_to = $initial_reply_to || ' ' ;
686+ my $tpl_in_reply_to = $initial_in_reply_to || ' ' ;
687+ my $tpl_reply_to = $reply_to || ' ' ;
685688
686689 print $c <<EOT1 , Git::prefix_lines(" GIT: " , __ <<EOT2 ), <<EOT3 ;
687690From $tpl_sender # This line is ignored.
@@ -693,8 +696,9 @@ sub get_patch_subject {
693696Clear the body content if you don' t wish to send a summary.
694697EOT2
695698From: $tpl_sender
699+ Reply-To: $tpl_reply_to
696700Subject: $tpl_subject
697- In-Reply-To: $tpl_reply_to
701+ In-Reply-To: $tpl_in_reply_to
698702
699703EOT3
700704 for my $f (@files) {
@@ -733,7 +737,10 @@ sub get_patch_subject {
733737 $sender = delete($parsed_email{' From' });
734738 }
735739 if ($parsed_email{' In-Reply-To' }) {
736- $initial_reply_to = delete($parsed_email{' In-Reply-To' });
740+ $initial_in_reply_to = delete($parsed_email{' In-Reply-To' });
741+ }
742+ if ($parsed_email{' Reply-To' }) {
743+ $reply_to = delete($parsed_email{' Reply-To' });
737744 }
738745 if ($parsed_email{' Subject' }) {
739746 $initial_subject = delete($parsed_email{' Subject' });
@@ -916,16 +923,22 @@ sub expand_one_alias {
916923@initial_cc = process_address_list(@initial_cc );
917924@bcclist = process_address_list(@bcclist );
918925
919- if ($thread && !defined $initial_reply_to && $prompting ) {
920- $initial_reply_to = ask(
926+ if ($thread && !defined $initial_in_reply_to && $prompting ) {
927+ $initial_in_reply_to = ask(
921928 __(" Message-ID to be used as In-Reply-To for the first email (if any)? " ),
922929 default => " " ,
923930 valid_re => qr /\@ .*\. / , confirm_only => 1);
924931}
925- if (defined $initial_reply_to ) {
926- $initial_reply_to =~ s / ^\s *<?// ;
927- $initial_reply_to =~ s / >?\s *$// ;
928- $initial_reply_to = " <$initial_reply_to >" if $initial_reply_to ne ' ' ;
932+ if (defined $initial_in_reply_to ) {
933+ $initial_in_reply_to =~ s / ^\s *<?// ;
934+ $initial_in_reply_to =~ s / >?\s *$// ;
935+ $initial_in_reply_to = " <$initial_in_reply_to >" if $initial_in_reply_to ne ' ' ;
936+ }
937+
938+ if (defined $reply_to ) {
939+ $reply_to =~ s / ^\s +|\s +$// g ;
940+ ($reply_to ) = expand_aliases($reply_to );
941+ $reply_to = sanitize_address($reply_to );
929942}
930943
931944if (!defined $smtp_server ) {
@@ -945,7 +958,7 @@ sub expand_one_alias {
945958}
946959
947960# Variables we set as part of the loop over files
948- our ($message_id , %mail , $subject , $reply_to , $references , $message ,
961+ our ($message_id , %mail , $subject , $in_reply_to , $references , $message ,
949962 $needs_confirm , $message_num , $ask_default );
950963
951964sub extract_valid_address {
@@ -1354,11 +1367,14 @@ sub send_message {
13541367 if ($use_xmailer ) {
13551368 $header .= " X-Mailer: git-send-email $gitversion \n " ;
13561369 }
1357- if ($reply_to ) {
1370+ if ($in_reply_to ) {
13581371
1359- $header .= " In-Reply-To: $reply_to \n " ;
1372+ $header .= " In-Reply-To: $in_reply_to \n " ;
13601373 $header .= " References: $references \n " ;
13611374 }
1375+ if ($reply_to ) {
1376+ $header .= " Reply-To: $reply_to \n " ;
1377+ }
13621378 if (@xh ) {
13631379 $header .= join (" \n " , @xh ) . " \n " ;
13641380 }
@@ -1533,8 +1549,8 @@ sub send_message {
15331549 return 1;
15341550}
15351551
1536- $reply_to = $initial_reply_to ;
1537- $references = $initial_reply_to || ' ' ;
1552+ $in_reply_to = $initial_in_reply_to ;
1553+ $references = $initial_in_reply_to || ' ' ;
15381554$subject = $initial_subject ;
15391555$message_num = 0;
15401556
@@ -1744,9 +1760,9 @@ sub send_message {
17441760
17451761 # set up for the next message
17461762 if ($thread && $message_was_sent &&
1747- ($chain_reply_to || !defined $reply_to || length ($reply_to ) == 0 ||
1763+ ($chain_reply_to || !defined $in_reply_to || length ($in_reply_to ) == 0 ||
17481764 $message_num == 1)) {
1749- $reply_to = $message_id ;
1765+ $in_reply_to = $message_id ;
17501766 if (length $references > 0) {
17511767 $references .= " \n $message_id " ;
17521768 } else {
0 commit comments