@@ -1502,16 +1502,7 @@ sub file_name_is_absolute {
15021502 return File::Spec::Functions::file_name_is_absolute($path );
15031503}
15041504
1505- # Prepares the email, then asks the user what to do.
1506- #
1507- # If the user chooses to send the email, it's sent and 1 is returned.
1508- # If the user chooses not to send the email, 0 is returned.
1509- # If the user decides they want to make further edits, -1 is returned and the
1510- # caller is expected to call send_message again after the edits are performed.
1511- #
1512- # If an error occurs sending the email, this just dies.
1513-
1514- sub send_message {
1505+ sub gen_header {
15151506 my @recipients = unique_email_list(@to );
15161507 @cc = (grep { my $cc = extract_valid_address_or_die($_ );
15171508 not grep { $cc eq $_ || $_ =~ / <\Q ${cc} \E >$ / } @recipients
@@ -1553,6 +1544,22 @@ sub send_message {
15531544 if (@xh ) {
15541545 $header .= join (" \n " , @xh ) . " \n " ;
15551546 }
1547+ my $recipients_ref = \@recipients ;
1548+ return ($recipients_ref , $to , $date , $gitversion , $cc , $ccline , $header );
1549+ }
1550+
1551+ # Prepares the email, then asks the user what to do.
1552+ #
1553+ # If the user chooses to send the email, it's sent and 1 is returned.
1554+ # If the user chooses not to send the email, 0 is returned.
1555+ # If the user decides they want to make further edits, -1 is returned and the
1556+ # caller is expected to call send_message again after the edits are performed.
1557+ #
1558+ # If an error occurs sending the email, this just dies.
1559+
1560+ sub send_message {
1561+ my ($recipients_ref , $to , $date , $gitversion , $cc , $ccline , $header ) = gen_header();
1562+ my @recipients = @$recipients_ref ;
15561563
15571564 my @sendmail_parameters = (' -i' , @recipients );
15581565 my $raw_from = $sender ;
@@ -1742,11 +1749,8 @@ sub send_message {
17421749$references = $initial_in_reply_to || ' ' ;
17431750$message_num = 0;
17441751
1745- # Prepares the email, prompts the user, sends it out
1746- # Returns 0 if an edit was done and the function should be called again, or 1
1747- # otherwise.
1748- sub process_file {
1749- my ($t ) = @_ ;
1752+ sub pre_process_file {
1753+ my ($t , $quiet ) = @_ ;
17501754
17511755 open my $fh , " <" , $t or die sprintf (__(" can't open file %s " ), $t );
17521756
@@ -1900,9 +1904,9 @@ sub process_file {
19001904 }
19011905 close $fh ;
19021906
1903- push @to , recipients_cmd(" to-cmd" , " to" , $to_cmd , $t )
1907+ push @to , recipients_cmd(" to-cmd" , " to" , $to_cmd , $t , $quiet )
19041908 if defined $to_cmd ;
1905- push @cc , recipients_cmd(" cc-cmd" , " cc" , $cc_cmd , $t )
1909+ push @cc , recipients_cmd(" cc-cmd" , " cc" , $cc_cmd , $t , $quiet )
19061910 if defined $cc_cmd && !$suppress_cc {' cccmd' };
19071911
19081912 if ($broken_encoding {$t } && !$has_content_type ) {
@@ -1961,6 +1965,15 @@ sub process_file {
19611965 @initial_to = @to ;
19621966 }
19631967 }
1968+ }
1969+
1970+ # Prepares the email, prompts the user, and sends it out
1971+ # Returns 0 if an edit was done and the function should be called again, or 1
1972+ # on the email being successfully sent out.
1973+ sub process_file {
1974+ my ($t ) = @_ ;
1975+
1976+ pre_process_file($t , $quiet );
19641977
19651978 my $message_was_sent = send_message();
19661979 if ($message_was_sent == -1) {
@@ -2009,7 +2022,7 @@ sub process_file {
20092022# Execute a command (e.g. $to_cmd) to get a list of email addresses
20102023# and return a results array
20112024sub recipients_cmd {
2012- my ($prefix , $what , $cmd , $file ) = @_ ;
2025+ my ($prefix , $what , $cmd , $file , $quiet ) = @_ ;
20132026
20142027 my @addresses = ();
20152028 open my $fh , " -|" , " $cmd \Q $file \E "
0 commit comments