Docs: send-email: Put options back into alphabetical order
RFC PATCH 1/10 Docs: send-email: Put options back into alphabetical order
I also wrote a comment block as a warning to trespassers.
--- Documentation/git-send-email.txt | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-)
Documentation/git-send-email.txt +15 -11
@@ -32,6 +32,10 @@ script This format expects the first line of the file to contain the "Cc:" value and the "Subject:" of the message as the second line. +///////////////////////////////////////////////////////////////////////////////////// +//// Within each category (Composing, Sending, Automating, and Administering), //// +//// options are to be given in alphabetical order. Please maintain this layout. //// +///////////////////////////////////////////////////////////////////////////////////// OPTIONS -------
@@ -39,6 +43,11 @@ OPTIONS Composing ~~~~~~~~~ +--annotate:: + Review each patch you're about to send in an editor. The setting + 'sendemail.multiedit' defines if this will spawn one editor per patch + or one for all of them at once. + --bcc=<address>:: Specify a "Bcc:" value for each email. Default is the value of 'sendemail.bcc'.
@@ -51,11 +60,6 @@ The --bcc option must be repeated for each user you want on the bcc list. + The --cc option must be repeated for each user you want on the cc list. ---annotate:: - Review each patch you're about to send in an editor. The setting - 'sendemail.multiedit' defines if this will spawn one editor per patch - or one for all of them at once. - --compose:: Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an introductory message for the patch series.
@@ -230,6 +234,12 @@ have been specified, in which case default to 'compose'. --dry-run:: Do everything except actually send the emails. +--[no-]format-patch:: + When an argument may be understood either as a reference or as a file name, + choose to understand it as a format-patch argument ('--format-patch') + or as a file name ('--no-format-patch'). By default, when such a conflict + occurs, git send-email will fail. + --quiet:: Make git-send-email less verbose. One line per email should be all that is output.
@@ -246,12 +256,6 @@ have been specified, in which case default to 'compose'. Default is the value of 'sendemail.validate'; if this is not set, default to '--validate'. ---[no-]format-patch:: - When an argument may be understood either as a reference or as a file name, - choose to understand it as a format-patch argument ('--format-patch') - or as a file name ('--no-format-patch'). By default, when such a conflict - occurs, git send-email will fail. - CONFIGURATION -------------
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 2/10 Docs: send-email: Remove superfluous information in CONFIGURATION
In particular, sendemail.confirm was removed, because it's already described along with its corresponding option.
There is now a comment block warning trespassers.
--- Documentation/git-send-email.txt | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
Documentation/git-send-email.txt +5 -6
@@ -257,6 +257,11 @@ Default is the value of 'sendemail.validate'; if this is not set, default to '--validate'. +////////////////////////////////////////////////////////////////////////////// +//// Only list configuration variables that can't be listed and described //// +//// with a corresponding option above //// +////////////////////////////////////////////////////////////////////////////// + CONFIGURATION -------------
@@ -274,12 +279,6 @@ sendemail.multiedit:: summary when '--compose' is used). If false, files will be edited one after the other, spawning a new editor each time. -sendemail.confirm:: - Sets the default for whether to confirm before sending. Must be - one of 'always', 'never', 'cc', 'compose', or 'auto'. See '--confirm' - in the previous section for the meaning of these values. - - Author ------ Written by Ryan Anderson <[email protected]>
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 3/10 send-email: Cleanup the usage text and docs a bit
All usage text lines should be < 80 characters.
A port number in --smtp-server is no longer handled, so the suggestion has been removed.
--chain-reply-to doesn't take an argument.
--- Documentation/git-send-email.txt | 17 +++++++------ git-send-email.perl | 47 +++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 29 deletions(-)
Documentation/git-send-email.txt +9 -8
@@ -77,8 +77,9 @@ Missing From or In-Reply-To headers will be prompted for. the value GIT_COMMITTER_IDENT, as returned by "git var -l". The user will still be prompted to confirm this entry. ---in-reply-to=<identifier>:: - Specify the contents of the first In-Reply-To header. +--in-reply-to=<message-id>:: + Specify the contents of the first In-Reply-To header; + include the angle brackets '<' and '>'. Subsequent emails will refer to the previous email instead of this if --chain-reply-to is set (the default) Only necessary if --compose is also set. If --compose
@@ -109,7 +110,7 @@ Sending the 'sendemail.envelopesender' configuration variable; if that is unspecified, choosing the envelope sender is left to your MTA. ---smtp-encryption=<encryption>:: +--smtp-encryption=<type>:: Specify the encryption to use, either 'ssl' or 'tls'. Any other value reverts to plain SMTP. Default is the value of 'sendemail.smtpencryption'.
@@ -159,7 +160,7 @@ Automating Output of this command must be single email address per line. Default is the value of 'sendemail.cccmd' configuration value. ---[no-]chain-reply-to=<identifier>:: +--[no-]chain-reply-to:: If this is set, each email will be sent as a reply to the previous email sent. If disabled with "--no-chain-reply-to", all emails after the first will be sent as replies to the first email sent. When using
@@ -167,11 +168,11 @@ Automating entire patch series. Default is the value of the 'sendemail.chainreplyto' configuration value; if that is unspecified, default to --chain-reply-to. ---identity=<identity>:: +--identity=<id>:: A configuration identity. When given, causes values in the - 'sendemail.<identity>' subsection to take precedence over + 'sendemail.<id>' subsection to take precedence over values in the 'sendemail' section. The default identity is - the value of 'sendemail.identity'. + the value of the 'sendemail.identity' configuration variable. --[no-]signed-off-by-cc:: If this is set, add emails found in Signed-off-by: or Cc: lines to the
@@ -215,7 +216,7 @@ specified, as well as 'body' if --no-signed-off-cc is specified. Administering ~~~~~~~~~~~~~ ---confirm=<mode>:: +--confirm=<when>:: Confirm just before sending: + --
git-send-email.perl +26 -21
72 lines not on this page · raw message
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 4/10 send-email: --smtp-server-port should take an integer
--- git-send-email.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
git-send-email.perl +1 -1
@@ -253,7 +253,7 @@ my $rc = GetOptions("sender|from=s" => \$sender, "bcc=s" => \@bcclist, "chain-reply-to!" => \$chain_reply_to, "smtp-server=s" => \$smtp_server, - "smtp-server-port=s" => \$smtp_server_port, + "smtp-server-port=i" => \$smtp_server_port, "smtp-user=s" => \$smtp_authuser, "smtp-pass:s" => \$smtp_authpass, "smtp-ssl" => sub { $smtp_encryption = 'ssl' },
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 5/10 send-email: Handle "GIT:" rather than "GIT: " during --compose
This should make things a little more robust in terms of user input; before, even the program got it wrong by outputting a line with only "GIT:", which was left in place as a header, because there would be no following space character.
Also, I cleaned up get_patch_subject().
--- git-send-email.perl | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-)
git-send-email.perl +12 -11
@@ -507,15 +507,16 @@ if (@files) { } sub get_patch_subject($) { - my $fn = shift; - open (my $fh, '<', $fn); - while (my $line = <$fh>) { - next unless ($line =~ /^Subject: (.*)$/); - close $fh; - return "GIT: $1\n"; + + my $patch = shift; + open (my $fh, '<', $patch); + + while (<$fh>) { + next unless (/^Subject: (.*)$/); + return $1; } - close $fh; - die "No subject line in $fn ?"; + + die "'Subject:' line expected in '$patch'"; } if ($compose) {
@@ -534,7 +535,7 @@ if ($compose) { print C <<EOT; From $tpl_sender # This line is ignored. -GIT: Lines beginning in "GIT: " will be removed. +GIT: Lines beginning in "GIT:" will be removed. GIT: Consider including an overall diffstat or table of contents GIT: for the patch you are writing. GIT:
@@ -545,7 +546,7 @@ In-Reply-To: $tpl_reply_to EOT for my $f (@files) { - print C get_patch_subject($f); + print C "GIT: ", get_patch_subject($f), "\n"; } close(C);
@@ -567,7 +568,7 @@ EOT my $in_body = 0; my $summary_empty = 1; while(<C>) { - next if m/^GIT: /; + next if m/^GIT:/; if ($in_body) { $summary_empty = 0 unless (/^\n$/); } elsif (/^\n$/) {
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 6/10 send-email: References: should only reference what is actually sent
If someone responded with a negative (n|no) to the confirmation, then the Message-ID of the discarded email is no longer used in the References: header of subsequent emails.
Consequently, send_message() now returns 1 if the message was sent and 0 otherwise.
--- git-send-email.perl | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
git-send-email.perl +10 -4
@@ -802,6 +802,10 @@ sub sanitize_address } +# returns 1 of the message was sent, 0 otherwise. +# In actuality, the whole program dies when a there +# is an error sending a message. + sub send_message { my @recipients = unique_email_list(@to);
@@ -870,7 +874,7 @@ X-Mailer: git-send-email $gitversion default => $ask_default); die "Send this email reply required" unless defined $_; if (/^n/i) { - return; + return 0; } elsif (/^q/i) { cleanup_compose_files(); exit(0);
@@ -951,7 +955,7 @@ X-Mailer: git-send-email $gitversion $smtp->data or die $smtp->message; $smtp->datasend("$header\n$message") or die $smtp->message; $smtp->dataend() or die $smtp->message; - $smtp->ok or die "Failed to send $subject\n".$smtp->message; + $smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message; } if ($quiet) { printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject);
@@ -972,6 +976,8 @@ X-Mailer: git-send-email $gitversion print "Result: OK\n"; } } + + return 1; } $reply_to = $initial_reply_to;
@@ -1132,10 +1138,10 @@ foreach my $t (@files) { @cc = (@initial_cc, @cc); - send_message(); + my $message_was_sent = send_message(); # set up for the next message - if ($chain_reply_to || !defined $reply_to || length($reply_to) == 0) { + if ($message_was_sent and $chain_reply_to || not defined $reply_to || length($reply_to) == 0) { $reply_to = $message_id; if (length $references > 0) { $references .= "\n $message_id";
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 7/10 send-email: Remove horrible mix of tabs and spaces
For the most part, I ran a search for all the lines that match:
^[\t]*[ ]+
and then I manually replaced the offending text with an appropriate number of tabs.
While scanning through the file, I also tried to format some of the code so as to obviate future mixing; I also fixed one horrendously egregious section of code, where someone was trying to be unnecessarily compact.
Currently, no lines match the following:
[\t]+[ ]+
[ ]+[\t]+So, it should be reasonably clean.
The whole file is still horrendous.
--- git-send-email.perl | 278 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 168 insertions(+), 110 deletions(-)
git-send-email.perl +168 -110
@@ -16,6 +16,14 @@ # and second line is the subject of the message. # +## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA! +## Currently, this file uses tabs (like the rest of git source) to +## delineate code structure. Do NOT under any circumstances mix tabs +## and spaces across lines that share a relationship in terms of layout. +## In fact, it would currently be best to use only tabs, so please set +## your editor(s) accordingly. This code is already trashy enough. Please +## don't make it worse. + use strict; use warnings; use Term::ReadLine;
@@ -116,19 +124,20 @@ sub format_2822_time { die ("local time offset greater than or equal to 24 hours\n"); } - return sprintf("%s, %2d %s %d %02d:%02d:%02d %s%02d%02d", - qw(Sun Mon Tue Wed Thu Fri Sat)[$localtm[6]], - $localtm[3], - qw(Jan Feb Mar Apr May Jun - Jul Aug Sep Oct Nov Dec)[$localtm[4]], - $localtm[5]+1900, - $localtm[2], - $localtm[1], - $localtm[0], - ($offset >= 0) ? '+' : '-', - abs($offhour), - $offmin, - ); + return sprintf( + "%s, %2d %s %d %02d:%02d:%02d %s%02d%02d", + qw(Sun Mon Tue Wed Thu Fri Sat)[$localtm[6]], + $localtm[3], + qw(Jan Feb Mar Apr May Jun + Jul Aug Sep Oct Nov Dec)[$localtm[4]], + $localtm[5]+1900, + $localtm[2], + $localtm[1], + $localtm[0], + ($offset >= 0) ? '+' : '-', + abs($offhour), + $offmin, + ); } my $have_email_valid = eval { require Email::Valid; 1 };
@@ -192,29 +201,29 @@ my ($validate, $confirm); my (@suppress_cc); my %config_bool_settings = ( - "thread" => [\$thread, 1], - "chainreplyto" => [\$chain_reply_to, 1], - "suppressfrom" => [\$suppress_from, undef], - "signedoffbycc" => [\$signed_off_by_cc, undef], - "signedoffcc" => [\$signed_off_by_cc, undef], # Deprecated - "validate" => [\$validate, 1], + "thread" => [\$thread, 1], + "chainreplyto" => [\$chain_reply_to, 1], + "suppressfrom" => [\$suppress_from, undef], + "signedoffbycc" => [\$signed_off_by_cc, undef], + "signedoffcc" => [\$signed_off_by_cc, undef], # Deprecated + "validate" => [\$validate, 1], ); my %config_settings = ( - "smtpserver" => \$smtp_server, - "smtpserverport" => \$smtp_server_port, - "smtpuser" => \$smtp_authuser, - "smtppass" => \$smtp_authpass, - "to" => \@to, - "cc" => \@initial_cc, - "cccmd" => \$cc_cmd, - "aliasfiletype" => \$aliasfiletype, - "bcc" => \@bcclist, - "aliasesfile" => \@alias_files, - "suppresscc" => \@suppress_cc, - "envelopesender" => \$envelope_sender, - "multiedit" => \$multiedit, - "confirm" => \$confirm, + "smtpserver" => \$smtp_server, + "smtpserverport" => \$smtp_server_port, + "smtpuser" => \$smtp_authuser, + "smtppass" => \$smtp_authpass, + "to" => \@to, + "cc" => \@initial_cc, + "cccmd" => \$cc_cmd, + "aliasfiletype" => \$aliasfiletype, + "bcc" => \@bcclist, + "aliasesfile" => \@alias_files, + "suppresscc" => \@suppress_cc, + "envelopesender" => \$envelope_sender, + "multiedit" => \$multiedit, + "confirm" => \$confirm, ); # Handle Uncouth Termination
@@ -245,37 +254,38 @@ $SIG{INT} = \&signal_handler; # Begin by accumulating all the variables (defined above), that we will end up # needing, first, from the command line: -my $rc = GetOptions("sender|from=s" => \$sender, - "in-reply-to=s" => \$initial_reply_to, - "subject=s" => \$initial_subject, - "to=s" => \@to, - "cc=s" => \@initial_cc, - "bcc=s" => \@bcclist, - "chain-reply-to!" => \$chain_reply_to, - "smtp-server=s" => \$smtp_server, - "smtp-server-port=i" => \$smtp_server_port, - "smtp-user=s" => \$smtp_authuser, - "smtp-pass:s" => \$smtp_authpass, - "smtp-ssl" => sub { $smtp_encryption = 'ssl' }, - "smtp-encryption=s" => \$smtp_encryption, - "identity=s" => \$identity, - "annotate" => \$annotate, - "compose" => \$compose, - "quiet" => \$quiet, - "cc-cmd=s" => \$cc_cmd, - "suppress-from!" => \$suppress_from, - "suppress-cc=s" => \@suppress_cc, - "signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc, - "confirm=s" => \$confirm, - "dry-run" => \$dry_run, - "envelope-sender=s" => \$envelope_sender, - "thread!" => \$thread, - "validate!" => \$validate, - "format-patch!" => \$format_patch, - ); +my $rc = GetOptions( + "sender|from=s" => \$sender, + "in-reply-to=s" => \$initial_reply_to, + "subject=s" => \$initial_subject, + "to=s" => \@to, + "cc=s" => \@initial_cc, + "bcc=s" => \@bcclist, + "chain-reply-to!" => \$chain_reply_to, + "smtp-server=s" => \$smtp_server, + "smtp-server-port=i" => \$smtp_server_port, + "smtp-user=s" => \$smtp_authuser, + "smtp-pass:s" => \$smtp_authpass, + "smtp-ssl" => sub { $smtp_encryption = 'ssl' }, + "smtp-encryption=s" => \$smtp_encryption, + "identity=s" => \$identity, + "annotate" => \$annotate, + "compose" => \$compose, + "quiet" => \$quiet, + "cc-cmd=s" => \$cc_cmd, + "suppress-from!" => \$suppress_from, + "suppress-cc=s" => \@suppress_cc, + "signed-off-cc|signed-off-by-cc!" => \$signed_off_by_cc, + "confirm=s" => \$confirm, + "dry-run" => \$dry_run, + "envelope-sender=s" => \$envelope_sender, + "thread!" => \$thread, + "validate!" => \$validate, + "format-patch!" => \$format_patch, +); unless ($rc) { - usage(); + usage(); } die "Cannot run git format-patch from outside a repository\n"
@@ -404,29 +414,55 @@ sub split_addrs { my %aliases; my %parse_alias = ( # multiline formats can be supported in the future - mutt => sub { my $fh = shift; while (<$fh>) { - if (/^\s*alias\s+(\S+)\s+(.*)$/) { - my ($alias, $addr) = ($1, $2); - $addr =~ s/#.*$//; # mutt allows # comments - # commas delimit multiple addresses - $aliases{$alias} = [ split_addrs($addr) ]; - }}}, - mailrc => sub { my $fh = shift; while (<$fh>) { - if (/^alias\s+(\S+)\s+(.*)$/) { - # spaces delimit multiple addresses - $aliases{$1} = [ split(/\s+/, $2) ]; - }}}, - pine => sub { my $fh = shift; my $f='\t[^\t]*'; - for (my $x = ''; defined($x); $x = $_) { + mutt => sub { + + my $fh = shift; + + while (<$fh>) { + if (/^\s*alias\s+(\S+)\s+(.*)$/) { + my ($alias, $addr) = ($1, $2); + $addr =~ s/#.*$//; # mutt allows # comments + # commas delimit multiple addresses + $aliases{$alias} = [ split_addrs($addr) ]; + } + } + }, + + mailrc => sub { + + my $fh = shift; + + while (<$fh>) { + if (/^alias\s+(\S+)\s+(.*)$/) { + # spaces delimit multiple addresses + $aliases{$1} = [ split(/\s+/, $2) ]; + } + } + }, + + pine => sub { + + my $fh = shift; + my $f='\t[^\t]*'; + + for (my $x = ''; defined($x); $x = $_) { chomp $x; - $x .= $1 while(defined($_ = <$fh>) && /^ +(.*)$/); + $x .= $1 while(defined($_ = <$fh>) && /^ +(.*)$/); $x =~ /^(\S+)$f\t\(?([^\t]+?)\)?(:?$f){0,2}$/ or next; $aliases{$1} = [ split_addrs($2) ]; - }}, - gnus => sub { my $fh = shift; while (<$fh>) { - if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) { - $aliases{$1} = [ $2 ]; - }}} + } + }, + + gnus => sub { + + my $fh = shift; + + while (<$fh>) { + if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) { + $aliases{$1} = [ $2 ]; + } + } + } ); if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {
@@ -574,10 +610,11 @@ EOT } elsif (/^\n$/) { $in_body = 1; if ($need_8bit_cte) { - print C2 "MIME-Version: 1.0\n", - "Content-Type: text/plain; ", - "charset=utf-8\n", - "Content-Transfer-Encoding: 8bit\n"; + print C2 + "MIME-Version: 1.0\n", + "Content-Type: text/plain; ", + "charset=utf-8\n", + "Content-Transfer-Encoding: 8bit\n"; } } elsif (/^MIME-Version:/i) { $need_8bit_cte = 0;
@@ -586,8 +623,8 @@ EOT my $subject = $initial_subject; $_ = "Subject: " . ($subject =~ /[^[:ascii:]]/ ? - quote_rfc2047($subject) : - $subject) . + quote_rfc2047($subject) : + $subject) . "\n"; } elsif (/^In-Reply-To:\s*(.+)\s*$/i) { $initial_reply_to = $1;
@@ -619,8 +656,10 @@ sub ask { my $resp; my $i = 0; return defined $default ? $default : undef - unless defined $term->IN and defined fileno($term->IN) and - defined $term->OUT and defined fileno($term->OUT); + unless defined $term->IN + and defined fileno($term->IN) + and defined $term->OUT + and defined fileno($term->OUT); while ($i++ < 10) { $resp = $term->readline($prompt); if (!defined $resp) { # EOF
@@ -640,8 +679,12 @@ sub ask { my $prompting = 0; if (!defined $sender) { $sender = $repoauthor || $repocommitter || ''; - $sender = ask("Who should the emails appear to be from? [$sender] ", - default => $sender); + + $sender = ask( + "Who should the emails appear to be from? [$sender] ", + default => $sender + ); + print "Emails will be sent from: ", $sender, "\n"; $prompting++; }
@@ -669,7 +712,8 @@ sub expand_aliases { if ($thread && !defined $initial_reply_to && $prompting) { $initial_reply_to = ask( - "Message-ID to be used as In-Reply-To for the first email? "); + "Message-ID to be used as In-Reply-To for the first email? " + ); } if (defined $initial_reply_to) { $initial_reply_to =~ s/^\s*<?//;
@@ -809,18 +853,22 @@ sub sanitize_address sub send_message { my @recipients = unique_email_list(@to); - @cc = (grep { my $cc = extract_valid_address($_); - not grep { $cc eq $_ } @recipients - } - map { sanitize_address($_) } - @cc); + + @cc = (grep + { + my $cc = extract_valid_address($_); + not grep { $cc eq $_ } @recipients + } + map { sanitize_address($_) } @cc + ); + my $to = join (",\n\t", @recipients); @recipients = unique_email_list(@recipients,@cc,@bcclist); @recipients = (map { extract_valid_address($_) } @recipients); my $date = format_2822_time($time++); my $gitversion = '@@GIT_VERSION@@'; if ($gitversion =~ m/..GIT_VERSION../) { - $gitversion = Git::version(); + $gitversion = Git::version(); } my $cc = join(", ", unique_email_list(@cc));
@@ -869,9 +917,13 @@ X-Mailer: git-send-email $gitversion print " To retain the current behavior, but squelch this message,\n"; print " run 'git config --global sendemail.confirm auto'.\n\n"; } - $_ = ask("Send this email? ([y]es|[n]o|[q]uit|[a]ll): ", - valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i, - default => $ask_default); + + $_ = ask( + "Send this email? ([y]es|[n]o|[q]uit|[a]ll): ", + valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i, + default => $ask_default + ); + die "Send this email reply required" unless defined $_; if (/^n/i) { return 0;
@@ -906,9 +958,13 @@ X-Mailer: git-send-email $gitversion } else { require Net::SMTP; - $smtp ||= Net::SMTP->new((defined $smtp_server_port) - ? "$smtp_server:$smtp_server_port" - : $smtp_server); + + $smtp ||= Net::SMTP->new( + (defined $smtp_server_port) + ? "$smtp_server:$smtp_server_port" + : $smtp_server + ); + if ($smtp_encryption eq 'tls') { require Net::SMTP::SSL; $smtp->command('STARTTLS');
@@ -1005,7 +1061,7 @@ foreach my $t (@files) { chomp($header[$#header]); s/^\s+/ /; $header[$#header] .= $_; - } else { + } else { push(@header, $_); } }
@@ -1123,9 +1179,9 @@ foreach my $t (@files) { } else { push @xh, - 'MIME-Version: 1.0', - "Content-Type: text/plain; charset=$author_encoding", - 'Content-Transfer-Encoding: 8bit'; + 'MIME-Version: 1.0', + "Content-Type: text/plain; charset=$author_encoding", + 'Content-Transfer-Encoding: 8bit'; } } }
@@ -1133,7 +1189,9 @@ foreach my $t (@files) { $needs_confirm = ( $confirm eq "always" or ($confirm =~ /^(?:auto|cc)$/ && @cc) or - ($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1)); + ($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1) + ); + $needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc); @cc = (@initial_cc, @cc);
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 8/10 send-email: Add --sleep for email throttling
The --sleep option provides a means for specifying that there should be a certain number of seconds of delay after sending a certain number of emails; see Documentation/git-send-email.txt
--- Documentation/git-send-email.txt | 30 +++++++++++++++ git-send-email.perl | 74 +++++++++++++++++++++++++++++++++++--- 2 files changed, 99 insertions(+), 5 deletions(-)
Documentation/git-send-email.txt +30 -0
@@ -168,6 +168,36 @@ Automating entire patch series. Default is the value of the 'sendemail.chainreplyto' configuration value; if that is unspecified, default to --chain-reply-to. +--sleep=<seconds>[,<burst>]:: + This option specfies that send-email should sleep for <seconds> + after sending <burst> messages as quickly as possible; <seconds> + should be an integer >= 0 and <burst> should be an integer >= 1. + This mode of operation attacks 2 problems: email throttling and + arrival disorder. Default is the value of the 'sendemail.sleep' + configuration variable, or '0' if that does not exist. ++ +By default, send-email tries to send one patch per email as quickly as +possible. Unfortunately, some email services restrict a user by refusing +to send more than some maximum number of email messages, M, in a given +period of seconds, S. This can be troublesome if the patch series has +more than M patches, because the server will ultimately refuse to send +some of them. In this case, simply pass '--sleep=S,M' or '--sleep S,M' +or set sendemail.sleep to 'S,M'. ++ +Moreover, the emails often arrive at the final destination out of order; +though send-email manipulates the date fields and usually chains subsequent +emails via the In-Reply-To headers, some mail viewers nevertheless insist +on presenting them by order of arrival. This may be mitigated by using +something like '--sleep 60' (the equivalent of '--sleep 60,1'), so that +there is a 60 second delay between sending each patch. ++ +*Note*: Because of varying routes and batching schemes, there is no delay +that can guarantee the correct arrival order. Obviously, one solution is to +choose an obscenely large number, so be prepared to run send-email in the +background. Of course, spreading emails across time makes it more likely +that unrelated email messages arrive between patches. Therefore, send-email +warns you if both --sleep and --no-chain-reply-to are used. + --identity=<id>:: A configuration identity. When given, causes values in the 'sendemail.<id>' subsection to take precedence over
git-send-email.perl +69 -5
122 lines not on this page · raw message
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 9/10 send-email: Minor cleanup of $smtp_server usage and send_message()
Note that the output has been changed; the server return code now appears after the `(Sendmail|Server):' line, rather than after the headers.
--- Documentation/git-send-email.txt | 3 +- git-send-email.perl | 39 +++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 16 deletions(-)
Documentation/git-send-email.txt +2 -1
@@ -135,7 +135,8 @@ user is prompted for a password while the input is masked for privacy. be specified by the 'sendemail.smtpserver' configuration option; the built-in default is `/usr/sbin/sendmail` or `/usr/lib/sendmail` if such program is available, or - `localhost` otherwise. + `127.0.0.1` otherwise. Also, if <host> is the empty string, + then a built-in default is used. --smtp-server-port=<port>:: Specifies a port different from the default port (SMTP
git-send-email.perl +24 -15
@@ -196,7 +196,8 @@ sub do_edit { # Variables with corresponding config settings my ($sleep, $thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd); -my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption); +my ($smtp_server, $smtp_server_is_a_command); +my ($smtp_server_port, $smtp_authuser, $smtp_encryption); my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts); my ($validate, $confirm); my (@suppress_cc);
@@ -761,14 +762,18 @@ if (defined $initial_reply_to) { $initial_reply_to = "<$initial_reply_to>" if $initial_reply_to ne ''; } -if (!defined $smtp_server) { +if (defined $smtp_server and $smtp_server ne '') { + $smtp_server_is_a_command = ($smtp_server =~ m{^/}); +} else { foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) { if (-x $_) { $smtp_server = $_; + $smtp_server_is_a_command = 1; last; } } - $smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug* + $smtp_server_is_a_command = 0; + $smtp_server ||= '127.0.0.1'; } if ($compose && $compose > 0) {
@@ -977,7 +982,7 @@ X-Mailer: git-send-email $gitversion if ($dry_run) { # We don't want to send the email. - } elsif ($smtp_server =~ m#^/#) { + } elsif ($smtp_server_is_a_command) { my $pid = open my $sm, '|-'; defined $pid or die $!; if (!$pid) {
@@ -1053,24 +1058,28 @@ X-Mailer: git-send-email $gitversion $smtp->dataend() or die $smtp->message; $smtp->code =~ /250|200/ or die "Failed to send $subject\n".$smtp->message; } + + print 'Dry-' if $dry_run; + if ($quiet) { - printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject); + print "Sent $subject\n"; } else { - print (($dry_run ? "Dry-" : "")."OK. Log says:\n"); - if ($smtp_server !~ m#^/#) { + print "OK. Log says:\n"; + + if ($smtp_server_is_a_command) { + print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n"; + print "Result: OK\n"; + } else { print "Server: $smtp_server\n"; + + $dry_run and print "Result: OK\n" or + print "Result: ", $smtp->code, ' ', ($smtp->message =~ /\n([^\n]+\n)$/s), "\n"; + print "MAIL FROM:<$raw_from>\n"; print "RCPT TO:".join(',',(map { "<$_>" } @recipients))."\n"; - } else { - print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n"; } + print $header, "\n"; - if ($smtp) { - print "Result: ", $smtp->code, ' ', - ($smtp->message =~ /\n([^\n]+\n)$/s), "\n"; - } else { - print "Result: OK\n"; - } } return 1;
Signature · 1 line
1.6.2.2.479.g2aec
RFC PATCH 10/10 send-email: --compose takes optional argument to existing file
Now, a user may specify an existing (in-progress) file to use as the introductory/summary email.
The file is opened for any additional editing as usual, but it is not deleted upon normal termination.
There are also a number of fixes to how the internals and temporaries are handled.
--- Documentation/git-send-email.txt | 39 ++++++-- git-send-email.perl | 190 ++++++++++++++++++++++++-------------- 2 files changed, 151 insertions(+), 78 deletions(-)
Documentation/git-send-email.txt +30 -9
@@ -60,17 +60,38 @@ The --bcc option must be repeated for each user you want on the bcc list. + The --cc option must be repeated for each user you want on the cc list. ---compose:: - Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an - introductory message for the patch series. +--compose[=<path>]:: + Use `$GIT_EDITOR`, 'core.editor', `$VISUAL`, or `$EDITOR`, or + `vi` to edit an introductory message for the patch series. A + path for the intermediate composition may be given. If the path + doesn't exist, a file with default contents is created at the + path and opened for editing. If the path does exist, then the + file at that path is opened for editing as-is. If no path is + specified, a new temporary file is created with some default + contents. Upon the successful completion of send-email, all + temporary files are automatically unlinked (deleted). However, + if send-email is terminated by a trappable signal, then this + temporary file is not unlinked, and the user is informed of its + path. + -When '--compose' is used, git send-email will use the From, Subject, and -In-Reply-To headers specified in the message. If the body of the message -(what you type after the headers and a blank line) only contains blank -(or GIT: prefixed) lines the summary won't be sent, but From, Subject, -and In-Reply-To headers will be used unless they are removed. +The user actually composes what will become a valid email message; +therefore, the message must have the following form (as described in +`RFC 822`): + -Missing From or In-Reply-To headers will be prompted for. + <headers> + <blank line> + <body> ++ +In particular, `<headers>` must contain the "`Subject`" header. Once the +user saves the message and quits the editor, this intermediate message is +transformed into the final email message by removing all lines that begin +with "`GIT:`". If the `<body>` of the final version is empty, then the +email is not sent, and send-email proceeds as if '--compose' had never been +used. ++ +The "`From`", "`Subject`", and "`In-Reply-To`" headers are taken directly +from the message; missing "`From`" or "`In-Reply-To`" headers will be +prompted for. --from=<address>:: Specify the sender of the emails. This will default to
git-send-email.perl +121 -69
280 lines not on this page · raw message
Signature · 1 line
1.6.2.2.479.g2aec
Re: [PATCH RFC 10/10] send-email: --compose takes optional argument to existing file
Heya,
Documentation/git-send-email.txt The --bcc option must be repeated for each user you want on the bcc list. · line 90
Quoted 4 lines · Michael Witten
Now, a user may specify an existing (in-progress) file to use as
Documentation/git-send-email.txt +3
-0+with "`GIT:`". If the `<body>` of the final version is empty, then the +email is not sent, and send-email proceeds as if '--compose' had never been +used.
Ouch! Wouldn't it be better to abort instead? Allover git we abort on empty commit messages and the like, why not here?
Signature · 3 lines
Cheers, Sverre Rabbelier
Re: [PATCH RFC 10/10] send-email: --compose takes optional argument to existing file
Quoted 2 lines · Sverre Rabbelier
Ouch! Wouldn't it be better to abort instead? Allover git we abort on empty commit messages and the like, why not here?
I was just following the original behavior. I don't really mind either way.
Re: [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message()
In reply to Michael WittenDocumentation/git-send-email.txt user is prompted for a password while the input is masked for privacy. · line 139
Quoted 7 lines · Michael Witten <mfwitten <at> gmail.com> writes:
Documentation/git-send-email.txt +2
-1be specified by the 'sendemail.smtpserver' configuration option; the built-in default is `/usr/sbin/sendmail` or `/usr/lib/sendmail` if such program is available, or - `localhost` otherwise. + `127.0.0.1` otherwise. Also, if <host> is the empty string, + then a built-in default is used.
Does this help anyone? localhost at least doesn't change when/if ipv6 is used, whereas '127.0.0.1' is only for ipv4.
Re: [PATCH RFC 09/10] send-email: Minor cleanup of $smtp_server usage and send_message()
Quoted 10 lines · Stephen Boyd
Documentation/git-send-email.txt user is prompted for a password while the input is masked for privacy. · line 139
Quoted 7 lines · Michael Witten <mfwitten <at> gmail.com> writes:
be specified by the 'sendemail.smtpserver' configuration option; the built-in default is
/usr/sbin/sendmailor/usr/lib/sendmailif such program is available, orDocumentation/git-send-email.txt +2
-1- `localhost` otherwise. + `127.0.0.1` otherwise. Also, if <host> is the empty string, + then a built-in default is used.
Quoted 2 lines
Does this help anyone? localhost at least doesn't change when/if ipv6 is used, whereas '127.0.0.1' is only for ipv4.
Ah. Good point. I'll get rid of that change.
Re: [PATCH RFC 08/10] send-email: Add --sleep for email throttling
In reply to Michael Wittengit-send-email.perl foreach my $setting (values %config_bool_settings) { · line 375
Quoted 2 lines · Michael Witten
git-send-email.perl +2
-0+if (defined $sleep) {{ +}}
What's the double-brackets about?
j.
Re: [PATCH RFC 08/10] send-email: Add --sleep for email throttling
In reply to Michael WittenQuoted 5 lines · Jay Soffian
git-send-email.perl foreach my $setting (values %config_bool_settings) { · line 375
Quoted 2 lines · Michael Witten
git-send-email.perl +2
-0+if (defined $sleep) {{ +}}What's the double-brackets about?
The {} that form the true-body of the if statement don't actually denote a block. The extra layer of {} is explicitly creating a block. This is done, because in Perl, blocks can be thought of as loops that execute one iteration, so you can use all of the loop flow-control operators 'redo', 'last', and 'next'.
In this case, I wanted to use 'last' to jump out of --sleep setup should the user decide to do so, because I think it's cleaner than a goto or variable check or superfluous loop:
if (defined $sleep) {{
unless ($chain_reply_to) {
...
/^b/ or
/^s/ and $chain_reply_to = 1 or
/^c/ and $sleep = undef, last or # forget --sleep was ever used
/^n/ and $chain_reply_to = 1, $sleep = undef, last or # forget --sleep was ever used
/^q/ and exit;
}
...
}}
# last jumps to hereAnyway, this particular behavior was requested (and seems reasonable):
http://marc.info/?l=git&m=123929919621279&w=2
Sincerely,
Michael Witten
Re: [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces
In reply to Michael WittenHeya,
git-send-email.perl line 25
Quoted 7 lines · Michael Witten
git-send-email.perl +7
-0+## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA! +## Currently, this file uses tabs (like the rest of git source) to +## delineate code structure. Do NOT under any circumstances mix tabs +## and spaces across lines that share a relationship in terms of layout. +## In fact, it would currently be best to use only tabs, so please set +## your editor(s) accordingly. This code is already trashy enough. Please +## don't make it worse.
Isn't this a bit overkill? In fact, isn't it overkill a lot?
Signature · 3 lines
Cheers, Sverre Rabbelier
Re: [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces
Quoted 1 line · Sverre Rabbelier
Isn't this a bit overkill? In fact, isn't it overkill a lot?
;-D
In my experience... NO.
Re: [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces
In reply to Sverre RabbelierQuoted 9 lines · Sverre Rabbelier
git-send-email.perl line 25
Quoted 7 lines
git-send-email.perl +7
-0+## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA! +## Currently, this file uses tabs (like the rest of git source) to +## delineate code structure. Do NOT under any circumstances mix tabs +## and spaces across lines that share a relationship in terms of layout. +## In fact, it would currently be best to use only tabs, so please set +## your editor(s) accordingly. This code is already trashy enough. Please +## don't make it worse.Isn't this a bit overkill? In fact, isn't it overkill a lot?
"Bizarre" is the word I'd use...
[There are places to whine about whitespace conventions, but that place isn't giant screaming comments in individual source files...]
-miles
Signature · 1 line
Admiration, n. Our polite recognition of another's resemblance to ourselves.
Re: [PATCH RFC 07/10] send-email: Remove horrible mix of tabs and spaces
Quoted 11 lines · Miles Bader
Quoted 9 lines · Sverre Rabbelier
git-send-email.perl line 25
Quoted 7 lines
git-send-email.perl +7
-0+## WARNING! ACHTUNG! ATTENTION! ADVERTENCIA! +## Currently, this file uses tabs (like the rest of git source) to +## delineate code structure. Do NOT under any circumstances mix tabs +## and spaces across lines that share a relationship in terms of layout. +## In fact, it would currently be best to use only tabs, so please set +## your editor(s) accordingly. This code is already trashy enough. Please +## don't make it worse.Isn't this a bit overkill? In fact, isn't it overkill a lot?
Quoted 1 line
"Bizarre" is the word I'd use...
Whatever you say, Master Bader.
Re: [PATCH RFC 06/10] send-email: References: should only reference what is actually sent
In reply to Michael WittenQuoted 2 lines · Michael Witten <mfwitten <at> gmail.com> writes:
+# returns 1 of the message was sent, 0 otherwise.
s/of/if/
Re: [PATCH RFC 06/10] send-email: References: should only reference what is actually sent
Quoted 6 lines · Stephen Boyd
Quoted 2 lines · Michael Witten <mfwitten <at> gmail.com> writes:
+# returns 1 of the message was sent, 0 otherwise.
s/of/if/
Woops! Thanks!
Re: [PATCH RFC 02/10] Docs: send-email: Remove superfluous information in CONFIGURATION
In reply to Michael WittenQuoted 2 lines · Michael Witten <mfwitten <at> gmail.com> writes:
There is now a comment block warning trespassers.
This patch and the previous have these comment block warnings which look ugly to me. Maybe we should make a DocumentationGuidelines, in the same spirit as CodingGuidelines where we can place these policies.
Also, the alphabetical ordering of patch 1 is nice, but if we want to do this we should probably change every git-<command>.txt to be consistent.