From 2db9b49c6c19d3edaa3c20147f7d9f29588433df Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 1 Oct 2007 14:42:42 +0200 Subject: git-send-email: add a new sendemail.to configuration variable Some projects prefer to receive patches via a given email address. In these cases, it's handy to configure that address once. Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- git-send-email.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 62e1429733..96051bc01e 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -191,6 +191,7 @@ my %config_settings = ( "smtpserverport" => \$smtp_server_port, "smtpuser" => \$smtp_authuser, "smtppass" => \$smtp_authpass, + "to" => \@to, "cccmd" => \$cc_cmd, "aliasfiletype" => \$aliasfiletype, "bcc" => \@bcclist, -- cgit v1.2.3 From 620bb245b945531bb6e08016d5f28caf9e797786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Wed, 7 Nov 2007 08:34:12 +0100 Subject: send-email: apply --suppress-from to S-o-b and cc-cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Cc: Ryan Anderson Signed-off-by: Junio C Hamano --- git-send-email.perl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 96051bc01e..f4b8f96511 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -88,8 +88,7 @@ Options: --smtp-ssl If set, connects to the SMTP server using SSL. - --suppress-from Suppress sending emails to yourself if your address - appears in a From: line. Defaults to off. + --suppress-from Suppress sending emails to yourself. Defaults to off. --thread Specify that the "In-Reply-To:" header should be set on all emails. Defaults to on. @@ -730,6 +729,7 @@ foreach my $t (@files) { if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) { my $c = $2; chomp $c; + next if ($c eq $sender and $suppress_from); push @cc, $c; printf("(sob) Adding cc: %s from line '%s'\n", $c, $_) unless $quiet; @@ -745,6 +745,7 @@ foreach my $t (@files) { my $c = $_; $c =~ s/^\s*//g; $c =~ s/\n$//g; + next if ($c eq $sender and $suppress_from); push @cc, $c; printf("(cc-cmd) Adding cc: %s from: '%s'\n", $c, $cc_cmd) unless $quiet; -- cgit v1.2.3 From cb6c162fba3fe3e1333b48c6062c18108c41fb82 Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Thu, 8 Nov 2007 19:56:28 +0100 Subject: git-send-email: Change the prompt for the subject of the initial message. I never understood what this prompt was asking for until I read the actual source code. I think this wording is much more understandable. Signed-off-by: Benoit Sigoure Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 9547cc37a1..8760cf88a5 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -303,7 +303,7 @@ sub expand_aliases { if (!defined $initial_subject && $compose) { do { - $_ = $term->readline("What subject should the emails start with? ", + $_ = $term->readline("What subject should the initial email start with? ", $initial_subject); } while (!defined $_); $initial_subject = $_; -- cgit v1.2.3 From 8291db6f584076b60efa47d72c604b1949508ef8 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 16 Nov 2007 05:49:09 -0500 Subject: git-send-email: add charset header if we add encoded 'From' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We sometimes pick out the original rfc822 'From' header and include it in the body of the message. If the original author's name needs encoding, then we should specify that in the content-type header. If we already had a content-type header in the mail, then we may need to re-encode. The logic is there to detect this case, but it doesn't actually do the re-encoding. Signed-off-by: Jeff King Acked-by: Uwe Kleine-König Signed-off-by: Junio C Hamano --- git-send-email.perl | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 8760cf88a5..2b1f1b598c 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -468,11 +468,13 @@ $time = time - scalar $#files; sub unquote_rfc2047 { local ($_) = @_; - if (s/=\?utf-8\?q\?(.*)\?=/$1/g) { + my $encoding; + if (s/=\?([^?]+)\?q\?(.*)\?=/$2/g) { + $encoding = $1; s/_/ /g; s/=([0-9A-F]{2})/chr(hex($1))/eg; } - return "$_"; + return wantarray ? ($_, $encoding) : $_; } # use the simplest quoting being able to handle the recipient @@ -599,6 +601,9 @@ foreach my $t (@files) { open(F,"<",$t) or die "can't open file $t"; my $author = undef; + my $author_encoding; + my $has_content_type; + my $body_encoding; @cc = @initial_cc; @xh = (); my $input_format = undef; @@ -624,12 +629,20 @@ foreach my $t (@files) { next if ($suppress_from); } elsif ($1 eq 'From') { - $author = unquote_rfc2047($2); + ($author, $author_encoding) + = unquote_rfc2047($2); } printf("(mbox) Adding cc: %s from line '%s'\n", $2, $_) unless $quiet; push @cc, $2; } + elsif (/^Content-type:/i) { + $has_content_type = 1; + if (/charset="?[^ "]+/) { + $body_encoding = $1; + } + push @xh, $_; + } elsif (!/^Date:\s/ && /^[-A-Za-z]+:\s+\S/) { push @xh, $_; } @@ -686,6 +699,21 @@ foreach my $t (@files) { if (defined $author) { $message = "From: $author\n\n$message"; + if (defined $author_encoding) { + if ($has_content_type) { + if ($body_encoding eq $author_encoding) { + # ok, we already have the right encoding + } + else { + # uh oh, we should re-encode + } + } + else { + push @xh, + 'MIME-Version: 1.0', + "Content-Type: text/plain; charset=$author_encoding"; + } + } } send_message(); -- cgit v1.2.3 From b7f30e0a972ab90a0f7720a7d6411822eb796ea3 Mon Sep 17 00:00:00 2001 From: "David D. Kilzer" Date: Sun, 18 Nov 2007 20:14:55 -0800 Subject: git-send-email: show all headers when sending mail As a git newbie, it was confusing to set an In-Reply-To header but then not see it printed when the git-send-email command was run. This patch prints all headers that would be sent to sendmail or an SMTP server instead of only printing From, Subject, Cc, To. It also removes the now-extraneous Date header after the "Log says" line. Added test to t/t9001-send-email.sh. Signed-off-by: David D. Kilzer Signed-off-by: Junio C Hamano --- git-send-email.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index fd0a4ad0c2..47afc56915 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -643,7 +643,7 @@ X-Mailer: git-send-email $gitversion if ($quiet) { printf (($dry_run ? "Dry-" : "")."Sent %s\n", $subject); } else { - print (($dry_run ? "Dry-" : "")."OK. Log says:\nDate: $date\n"); + print (($dry_run ? "Dry-" : "")."OK. Log says:\n"); if ($smtp_server !~ m#^/#) { print "Server: $smtp_server\n"; print "MAIL FROM:<$raw_from>\n"; @@ -651,7 +651,7 @@ X-Mailer: git-send-email $gitversion } else { print "Sendmail: $smtp_server ".join(' ',@sendmail_parameters)."\n"; } - print "From: $sanitized_sender\nSubject: $subject\nCc: $cc\nTo: $to\n\n"; + print $header, "\n"; if ($smtp) { print "Result: ", $smtp->code, ' ', ($smtp->message =~ /\n([^\n]+\n)$/s), "\n"; -- cgit v1.2.3 From 7ac17529297910c7b4502bdfa543ddec3f943413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Mon, 19 Nov 2007 03:00:26 -0800 Subject: send-email: Don't add To: recipients to the Cc: header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ask Bjørn Hansen Signed-off-by: Junio C Hamano --- git-send-email.perl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 47afc56915..990e44bf02 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -557,7 +557,11 @@ sub sanitize_address sub send_message { my @recipients = unique_email_list(@to); - @cc = (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); -- cgit v1.2.3 From 8641ee3dcbae749c42b7cf117ba3050e2cb95a93 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 20 Nov 2007 07:54:04 -0500 Subject: send-email: add transfer encoding header with content-type We add the content-type header only when we have non-7bit characters from the 'From' header, so we really need to specify the encoding (in other cases, where the commit text needed a content-type, git-format-patch will already have added the encoding header). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-send-email.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 2b1f1b598c..b03297c9d7 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -711,7 +711,8 @@ foreach my $t (@files) { else { push @xh, 'MIME-Version: 1.0', - "Content-Type: text/plain; charset=$author_encoding"; + "Content-Type: text/plain; charset=$author_encoding", + 'Content-Transfer-Encoding: 8bit'; } } } -- cgit v1.2.3 From 5f5b611805ed60a303ccbc07ebd9a5bac2dabb92 Mon Sep 17 00:00:00 2001 From: Wincent Colaiuta Date: Wed, 21 Nov 2007 13:35:05 +0100 Subject: Authenticate only once in git-send-email When using git-send-email with SMTP authentication sending a patch series would redundantly authenticate multiple times, once for each patch. In the worst case, this would actually prevent the series from being sent because the server would reply with a "5.5.0 Already Authenticated" status code which would derail the process. This commit teaches git-send-email to authenticate once and only once at the beginning of the series. Signed-off-by: Wincent Colaiuta Signed-off-by: Junio C Hamano --- git-send-email.perl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 9c6fa6441a..76baa8e431 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -145,6 +145,7 @@ sub format_2822_time { my $have_email_valid = eval { require Email::Valid; 1 }; my $smtp; +my $auth; sub unique_email_list(@); sub cleanup_compose_files(); @@ -635,7 +636,7 @@ X-Mailer: git-send-email $gitversion } if ((defined $smtp_authuser) && (defined $smtp_authpass)) { - $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message; + $auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message; } $smtp->mail( $raw_from ) or die $smtp->message; $smtp->to( @recipients ) or die $smtp->message; -- cgit v1.2.3 From ace72086bbe1cd59bc15a0e5b043bdb98335af00 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sun, 9 Dec 2007 18:17:28 +0100 Subject: git-send-email.perl: Really add angle brackets to In-Reply-To if necessary 3803bcea tried to fix this, but it only adds the branckes when the given In-Reply-To begins and ends with whitespaces. It also didn't do anything to the --in-reply-to argument. Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano --- git-send-email.perl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 76baa8e431..c0e1dd348c 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -367,10 +367,11 @@ if ($thread && !defined $initial_reply_to && $prompting) { } while (!defined $_); $initial_reply_to = $_; - $initial_reply_to =~ s/^\s+?\s+$/>/; } +$initial_reply_to =~ s/^\s*?\s*$/>/; + if (!defined $smtp_server) { foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) { if (-x $_) { -- cgit v1.2.3 From ace9c2a9dd7c9e54194998fc6b7c677dbb7d0902 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 10 Dec 2007 21:44:42 -0800 Subject: send-email: do not muck with initial-reply-to when unset. When not prompting, initial_reply_to can be left unset. Do not try to sanitize it and get useless warning. Signed-off-by: Junio C Hamano --- git-send-email.perl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index c0e1dd348c..1d6f466453 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -368,9 +368,10 @@ if ($thread && !defined $initial_reply_to && $prompting) { $initial_reply_to = $_; } - -$initial_reply_to =~ s/^\s*?\s*$/>/; +if (defined $initial_reply_to && $_ ne "") { + $initial_reply_to =~ s/^\s*?\s*$/>/; +} if (!defined $smtp_server) { foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) { -- cgit v1.2.3 From 4f3d37035a7c735a3b69f962656819f4ff7e4927 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 17 Dec 2007 15:51:34 -0500 Subject: git-send-email: avoid duplicate message-ids We used to unconditionally add a message-id to the outgoing email without bothering to check if it already had one. Instead, let's use the existing one. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-send-email.perl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index b03297c9d7..e8354c760b 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -527,7 +527,7 @@ sub send_message $ccline = "\nCc: $cc"; } my $sanitized_sender = sanitize_address($sender); - make_message_id(); + make_message_id() unless defined($message_id); my $header = "From: $sanitized_sender To: $to${ccline} @@ -643,6 +643,9 @@ foreach my $t (@files) { } push @xh, $_; } + elsif (/^Message-Id: (.*)/i) { + $message_id = $1; + } elsif (!/^Date:\s/ && /^[-A-Za-z]+:\s+\S/) { push @xh, $_; } @@ -728,6 +731,7 @@ foreach my $t (@files) { $references = "$message_id"; } } + $message_id = undef; } if ($compose) { -- cgit v1.2.3 From 0e0278baad8752da6c3b37495f005dc1dd6f799a Mon Sep 17 00:00:00 2001 From: Gustaf Hendeby Date: Sat, 22 Dec 2007 01:40:52 +0100 Subject: Make git send-email accept $EDITOR with arguments Currently git send-email does not accept $EDITOR with arguments, eg, emacs -nw, when starting an editor to produce a cover letter. This patch changes this by letting the shell handle the option parsing. Signed-off-by: Gustaf Hendeby Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 248d035088..e47994afc4 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -400,7 +400,7 @@ EOT close(C); my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi"; - system($editor, $compose_filename); + system('sh', '-c', '$0 $@', $editor, $compose_filename); open(C2,">",$compose_filename . ".final") or die "Failed to open $compose_filename.final : " . $!; -- cgit v1.2.3 From aa54892f5ada8282643dc7387b33261c7135d784 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 18 Jan 2008 09:19:36 -0500 Subject: send-email: detect invocation errors earlier We never even look at the command line arguments until after we have prompted the user for some information. So running "git send-email" without arguments would prompt for "from" and "to" headers, only to then die with "No patch files specified." Instead, let's try to do as much error checking as possible before getting user input. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-send-email.perl | 55 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index e47994afc4..7a86977ef1 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -314,6 +314,33 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) { ($sender) = expand_aliases($sender) if defined $sender; +# Now that all the defaults are set, process the rest of the command line +# arguments and collect up the files that need to be processed. +for my $f (@ARGV) { + if (-d $f) { + opendir(DH,$f) + or die "Failed to opendir $f: $!"; + + push @files, grep { -f $_ } map { +$f . "/" . $_ } + sort readdir(DH); + + } elsif (-f $f) { + push @files, $f; + + } else { + print STDERR "Skipping $f - not found.\n"; + } +} + +if (@files) { + unless ($quiet) { + print $_,"\n" for (@files); + } +} else { + print STDERR "\nNo patch files specified!\n\n"; + usage(); +} + my $prompting = 0; if (!defined $sender) { $sender = $repoauthor || $repocommitter; @@ -427,34 +454,6 @@ EOT @files = ($compose_filename . ".final"); } - -# Now that all the defaults are set, process the rest of the command line -# arguments and collect up the files that need to be processed. -for my $f (@ARGV) { - if (-d $f) { - opendir(DH,$f) - or die "Failed to opendir $f: $!"; - - push @files, grep { -f $_ } map { +$f . "/" . $_ } - sort readdir(DH); - - } elsif (-f $f) { - push @files, $f; - - } else { - print STDERR "Skipping $f - not found.\n"; - } -} - -if (@files) { - unless ($quiet) { - print $_,"\n" for (@files); - } -} else { - print STDERR "\nNo patch files specified!\n\n"; - usage(); -} - # Variables we set as part of the loop over files our ($message_id, %mail, $subject, $reply_to, $references, $message); -- cgit v1.2.3 From 747bbff9b9583642cd8702b7b559757a6960df00 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 18 Jan 2008 09:19:48 -0500 Subject: send-email: validate patches before sending anything We try to catch errors early so that we don't end up sending half of a broken patch series. Right now the only validation is checking that line-lengths are under the SMTP-mandated limit of 998. The validation parsing is very crude (it just checks each line length without understanding the mailbox format) but should work fine for this simple check. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-send-email.perl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 7a86977ef1..4e62c3f0e7 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -332,6 +332,11 @@ for my $f (@ARGV) { } } +foreach my $f (@files) { + my $error = validate_patch($f); + $error and die "fatal: $f: $error\nwarning: no patches were sent\n"; +} + if (@files) { unless ($quiet) { print $_,"\n" for (@files); @@ -837,3 +842,15 @@ sub unique_email_list(@) { } return @emails; } + +sub validate_patch { + my $fn = shift; + open(my $fh, '<', $fn) + or die "unable to open $fn: $!\n"; + while (my $line = <$fh>) { + if (length($line) > 998) { + return "$.: patch contains a line longer than 998 characters"; + } + } + return undef; +} -- cgit v1.2.3 From c764a0c2b6d8c94d90c95fa8170970c85a40665c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 18 Jan 2008 09:20:10 -0500 Subject: send-email: add no-validate option Since we are now sanity-checking the contents of patches and refusing to send ones with long lines, this knob provides a way for the user to override the new behavior (if, e.g., he knows his SMTP path will handle it). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-send-email.perl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 4e62c3f0e7..6c72952fcc 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -100,6 +100,8 @@ Options: --envelope-sender Specify the envelope sender used to send the emails. + --no-validate Don't perform any sanity checks on patches. + EOT exit(1); } @@ -177,6 +179,7 @@ my ($quiet, $dry_run) = (0, 0); my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd); my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl); my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts); +my ($no_validate); my %config_bool_settings = ( "thread" => [\$thread, 1], @@ -222,6 +225,7 @@ my $rc = GetOptions("sender|from=s" => \$sender, "dry-run" => \$dry_run, "envelope-sender=s" => \$envelope_sender, "thread!" => \$thread, + "no-validate" => \$no_validate, ); unless ($rc) { @@ -332,9 +336,11 @@ for my $f (@ARGV) { } } -foreach my $f (@files) { - my $error = validate_patch($f); - $error and die "fatal: $f: $error\nwarning: no patches were sent\n"; +if (!$no_validate) { + foreach my $f (@files) { + my $error = validate_patch($f); + $error and die "fatal: $f: $error\nwarning: no patches were sent\n"; + } } if (@files) { -- cgit v1.2.3 From 97394ee4304a8d336663df5da23a33efbe1ab46b Mon Sep 17 00:00:00 2001 From: Gustaf Hendeby Date: Mon, 21 Jan 2008 20:57:46 +0100 Subject: send-email, fix breakage in combination with --compose This fixes the subtile bug in git send-email that was introduced into git send-email with aa54892f5ada8282643dc7387b33261c7135d784 (send-email: detect invocation errors earlier), which caused no patches to be sent out if the --compose flag was used. Signed-off-by: Gustaf Hendeby Tested-by: Seth Falcon Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 6c72952fcc..a1a9d14b00 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -462,7 +462,7 @@ EOT exit(0); } - @files = ($compose_filename . ".final"); + @files = ($compose_filename . ".final", @files); } # Variables we set as part of the loop over files -- cgit v1.2.3 From 2363d7467dcd60467b3e694b3ba6f859bb226f5c Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Sun, 3 Feb 2008 19:53:56 -0500 Subject: git-send-email: ssh/login style password requests Whilst convenient, it is most unwise to record passwords in any place but one's brain. Moreover, it is especially foolish to store them in configuration files, even with access permissions set accordingly. git-send-email has been amended, so that if it detects an smtp username without a password, it promptly prompts for the password and masks the input for privacy. Furthermore, the argument to --smtp-pass has been rendered optional. The documentation has been updated to reflect these changes. Signed-off-by: Michael Witten Signed-off-by: Junio C Hamano --- git-send-email.perl | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index a1a9d14b00..fec55ea2df 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -157,7 +157,7 @@ my $compose_filename = ".msg.$$"; # Variables we fill in automatically, or via prompting: my (@to,@cc,@initial_cc,@bcclist,@xh, - $initial_reply_to,$initial_subject,@files,$author,$sender,$compose,$time); + $initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time); my $envelope_sender; @@ -177,7 +177,7 @@ my ($quiet, $dry_run) = (0, 0); # Variables with corresponding config settings my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd); -my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl); +my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_ssl); my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts); my ($no_validate); @@ -214,7 +214,7 @@ my $rc = GetOptions("sender|from=s" => \$sender, "smtp-server=s" => \$smtp_server, "smtp-server-port=s" => \$smtp_server_port, "smtp-user=s" => \$smtp_authuser, - "smtp-pass=s" => \$smtp_authpass, + "smtp-pass:s" => \$smtp_authpass, "smtp-ssl!" => \$smtp_ssl, "identity=s" => \$identity, "compose" => \$compose, @@ -647,9 +647,26 @@ X-Mailer: git-send-email $gitversion die "Unable to initialize SMTP properly. Is there something wrong with your config?"; } - if ((defined $smtp_authuser) && (defined $smtp_authpass)) { + if (defined $smtp_authuser) { + + if (!defined $smtp_authpass) { + + system "stty -echo"; + + do { + print "Password: "; + $_ = ; + print "\n"; + } while (!defined $_); + + chomp($smtp_authpass = $_); + + system "stty echo"; + } + $auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message; } + $smtp->mail( $raw_from ) or die $smtp->message; $smtp->to( @recipients ) or die $smtp->message; $smtp->data or die $smtp->message; -- cgit v1.2.3 From 874299760708e3bd4d63e9afa8da3fe8a7ddc006 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Sun, 3 Feb 2008 19:53:57 -0500 Subject: git-send-email: SIG{TERM,INT} handlers A single signal handler is used for both SIGTERM and SIGINT in order to clean up after an uncouth termination of git-send-email. In particular, the handler resets the text color (this cleanup was already present), turns on tty echoing (in case termination occurrs during a masked Password prompt), and informs the user of of any temporary files created by --compose. Signed-off-by: Michael Witten Signed-off-by: Junio C Hamano --- git-send-email.perl | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index fec55ea2df..14268fc1d4 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -24,8 +24,6 @@ use Data::Dumper; use Term::ANSIColor; use Git; -$SIG{INT} = sub { print color("reset"), "\n"; exit }; - package FakeTerm; sub new { my ($class, $reason) = @_; @@ -201,6 +199,29 @@ my %config_settings = ( "aliasesfile" => \@alias_files, ); +# Handle Uncouth Termination +sub signal_handler { + + # Make text normal + print color("reset"), "\n"; + + # SMTP password masked + system "stty echo"; + + # tmp files from --compose + if (-e $compose_filename) { + print "'$compose_filename' contains an intermediate version of the email you were composing.\n"; + } + if (-e ($compose_filename . ".final")) { + print "'$compose_filename.final' contains the composed email.\n" + } + + exit; +}; + +$SIG{TERM} = \&signal_handler; +$SIG{INT} = \&signal_handler; + # Begin by accumulating all the variables (defined above), that we will end up # needing, first, from the command line: -- cgit v1.2.3 From 8a7c56e1591ad5593883bb23fb6c5683a8a1a1a8 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Sun, 3 Feb 2008 19:53:58 -0500 Subject: git-send-email: Better handling of EOF Before, when the user sent the EOF control character, the prompts would be repeated on the same line as the previous prompt. Now, repeat prompts display on separate lines. Signed-off-by: Michael Witten Signed-off-by: Junio C Hamano --- git-send-email.perl | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 14268fc1d4..9d7c1f4671 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -376,9 +376,12 @@ if (@files) { my $prompting = 0; if (!defined $sender) { $sender = $repoauthor || $repocommitter; - do { + + while (1) { $_ = $term->readline("Who should the emails appear to be from? [$sender] "); - } while (!defined $_); + last if defined $_; + print "\n"; + } $sender = $_ if ($_); print "Emails will be sent from: ", $sender, "\n"; @@ -386,10 +389,14 @@ if (!defined $sender) { } if (!@to) { - do { - $_ = $term->readline("Who should the emails be sent to? ", - ""); - } while (!defined $_); + + + while (1) { + $_ = $term->readline("Who should the emails be sent to? ", ""); + last if defined $_; + print "\n"; + } + my $to = $_; push @to, split /,/, $to; $prompting++; @@ -411,19 +418,22 @@ sub expand_aliases { @bcclist = expand_aliases(@bcclist); if (!defined $initial_subject && $compose) { - do { - $_ = $term->readline("What subject should the initial email start with? ", - $initial_subject); - } while (!defined $_); + while (1) { + $_ = $term->readline("What subject should the initial email start with? ", $initial_subject); + last if defined $_; + print "\n"; + } + $initial_subject = $_; $prompting++; } if ($thread && !defined $initial_reply_to && $prompting) { - do { - $_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ", - $initial_reply_to); - } while (!defined $_); + while (1) { + $_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ", $initial_reply_to); + last if defined $_; + print "\n"; + } $initial_reply_to = $_; } @@ -474,9 +484,11 @@ EOT close(C); close(C2); - do { + while (1) { $_ = $term->readline("Send this email? (y|n) "); - } while (!defined $_); + last if defined $_; + print "\n"; + } if (uc substr($_,0,1) ne 'Y') { cleanup_compose_files(); -- cgit v1.2.3 From 656482830ddc4a4e2af132fabb118a25190439c2 Mon Sep 17 00:00:00 2001 From: David Brown Date: Tue, 25 Dec 2007 19:56:29 -0800 Subject: git-send-email: Generalize auto-cc recipient mechanism. There are a few options to git-send-email to suppress the automatic generation of 'Cc' fields: --suppress-from, and --signed-off-cc. However, there are other times that git-send-email automatically includes Cc'd recipients. This is not desirable for all development environments. Add a new option --suppress-cc, which can be specified one or more times to list the categories of auto-cc fields that should be suppressed. If not specified, it defaults to values to give the same behavior as specified by --suppress-from, and --signed-off-cc. The categories are: self - patch sender. Same as --suppress-from. author - patch author. cc - cc lines mentioned in the patch. cccmd - avoid running the cccmd. sob - signed off by lines. all - all non-explicit recipients Signed-off-by: David Brown Signed-off-by: Junio C Hamano --- git-send-email.perl | 56 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index a1a9d14b00..8de5789f66 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -88,6 +88,12 @@ Options: --smtp-ssl If set, connects to the SMTP server using SSL. + --suppress-cc Suppress the specified category of auto-CC. The category + can be one of 'author' for the patch author, 'self' to + avoid copying yourself, 'sob' for Signed-off-by lines, + 'cccmd' for the output of the cccmd, or 'all' to suppress + all of these. + --suppress-from Suppress sending emails to yourself. Defaults to off. --thread Specify that the "In-Reply-To:" header should be set on all @@ -180,12 +186,13 @@ my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd); my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl); my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts); my ($no_validate); +my (@suppress_cc); my %config_bool_settings = ( "thread" => [\$thread, 1], "chainreplyto" => [\$chain_reply_to, 1], - "suppressfrom" => [\$suppress_from, 0], - "signedoffcc" => [\$signed_off_cc, 1], + "suppressfrom" => [\$suppress_from, undef], + "signedoffcc" => [\$signed_off_cc, undef], "smtpssl" => [\$smtp_ssl, 0], ); @@ -199,6 +206,7 @@ my %config_settings = ( "aliasfiletype" => \$aliasfiletype, "bcc" => \@bcclist, "aliasesfile" => \@alias_files, + "suppresscc" => \@suppress_cc, ); # Begin by accumulating all the variables (defined above), that we will end up @@ -221,6 +229,7 @@ my $rc = GetOptions("sender|from=s" => \$sender, "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_cc, "dry-run" => \$dry_run, "envelope-sender=s" => \$envelope_sender, @@ -266,6 +275,35 @@ foreach my $setting (values %config_bool_settings) { ${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]})); } +# Set CC suppressions +my(%suppress_cc); +if (@suppress_cc) { + foreach my $entry (@suppress_cc) { + die "Unknown --suppress-cc field: '$entry'\n" + unless $entry =~ /^(all|cccmd|cc|author|self|sob)$/; + $suppress_cc{$entry} = 1; + } +} + +if ($suppress_cc{'all'}) { + foreach my $entry (qw (ccmd cc author self sob)) { + $suppress_cc{$entry} = 1; + } + delete $suppress_cc{'all'}; +} + +# If explicit old-style ones are specified, they trump --suppress-cc. +$suppress_cc{'self'} = $suppress_from if defined $suppress_from; +$suppress_cc{'sob'} = $signed_off_cc if defined $signed_off_cc; + +# Debugging, print out the suppressions. +if (0) { + print "suppressions:\n"; + foreach my $entry (keys %suppress_cc) { + printf " %-5s -> $suppress_cc{$entry}\n", $entry; + } +} + my ($repoauthor) = $repo->ident_person('author'); my ($repocommitter) = $repo->ident_person('committer'); @@ -711,11 +749,14 @@ foreach my $t (@files) { } elsif (/^(Cc|From):\s+(.*)$/) { if (unquote_rfc2047($2) eq $sender) { - next if ($suppress_from); + next if ($suppress_cc{'self'}); } elsif ($1 eq 'From') { ($author, $author_encoding) = unquote_rfc2047($2); + next if ($suppress_cc{'author'}); + } else { + next if ($suppress_cc{'cc'}); } printf("(mbox) Adding cc: %s from line '%s'\n", $2, $_) unless $quiet; @@ -742,7 +783,7 @@ foreach my $t (@files) { # line 2 = subject # So let's support that, too. $input_format = 'lots'; - if (@cc == 0) { + if (@cc == 0 && !$suppress_cc{'cc'}) { printf("(non-mbox) Adding cc: %s from line '%s'\n", $_, $_) unless $quiet; @@ -759,10 +800,11 @@ foreach my $t (@files) { } } else { $message .= $_; - if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) { + if (/^(Signed-off-by|Cc): (.*)$/i) { + next if ($suppress_cc{'sob'}); my $c = $2; chomp $c; - next if ($c eq $sender and $suppress_from); + next if ($c eq $sender and $suppress_cc{'self'}); push @cc, $c; printf("(sob) Adding cc: %s from line '%s'\n", $c, $_) unless $quiet; @@ -771,7 +813,7 @@ foreach my $t (@files) { } close F; - if (defined $cc_cmd) { + if (defined $cc_cmd && !$suppress_cc{'cccmd'}) { open(F, "$cc_cmd $t |") or die "(cc-cmd) Could not execute '$cc_cmd'"; while() { -- cgit v1.2.3 From 1ca3d6ed01774eab37e96d9c88b840ea618f97af Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Wed, 20 Feb 2008 00:55:07 -0500 Subject: send-email: squelch warning due to comparing undefined $_ to "" The check to see if initial_reply_to is defined was also comparing $_ to "" for a reason I cannot ascertain (looking at the commit which made the change didn't provide enlightenment), but if $_ is undefined, perl generates a warning. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index a1a9d14b00..8e6f3b22c8 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -406,7 +406,7 @@ if ($thread && !defined $initial_reply_to && $prompting) { $initial_reply_to = $_; } -if (defined $initial_reply_to && $_ ne "") { +if (defined $initial_reply_to) { $initial_reply_to =~ s/^\s*?\s*$/>/; } -- cgit v1.2.3 From 0fb7fc751d29cd1099556f71fc7c08158a6a78bc Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Thu, 21 Feb 2008 19:16:04 -0500 Subject: send-email: fix In-Reply-To regression Fix a regression introduced by 1ca3d6e (send-email: squelch warning due to comparing undefined $_ to "") where if the user was prompted for an initial In-Reply-To and didn't provide one, messages would be sent out with an invalid In-Reply-To of "<>" Also add test cases for the regression and the fix. A small modification was needed to allow send-email to take its replies from stdin if the environment variable GIT_SEND_EMAIL_NOTTY is set. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- git-send-email.perl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index ccb87a2d55..29b1105c4c 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -170,7 +170,9 @@ my $envelope_sender; my $repo = Git->repository(); my $term = eval { - new Term::ReadLine 'git-send-email'; + $ENV{"GIT_SEND_EMAIL_NOTTY"} + ? new Term::ReadLine 'git-send-email', \*STDIN, \*STDOUT + : new Term::ReadLine 'git-send-email'; }; if ($@) { $term = new FakeTerm "$@: going non-interactive"; @@ -476,8 +478,9 @@ if ($thread && !defined $initial_reply_to && $prompting) { $initial_reply_to = $_; } if (defined $initial_reply_to) { - $initial_reply_to =~ s/^\s*?\s*$/>/; + $initial_reply_to =~ s/^\s*?\s*$//; + $initial_reply_to = "<$initial_reply_to>" if $initial_reply_to ne ''; } if (!defined $smtp_server) { -- cgit v1.2.3