{"thread":{"id":"17797","subject":"[PATCH v2 0/3] send-email","startedAt":"2009-02-15T04:32:12Z","lastAt":"2009-02-15T05:07:31Z","messageCount":5,"participants":["Jay Soffian","Greg KH"],"isPatch":true,"patchVersion":2,"patchTotal":3},"messages":[{"id":"104723","messageId":"1234672335-54321-1-git-send-email-jaysoffian@gmail.com","threadId":"17797","inReplyTo":null,"subject":"[PATCH v2 0/3] send-email","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-15T04:32:12Z","receivedAt":"2009-02-15T04:32:12Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Junio,\n\nThere have been several messages on my send-email patches. I\nincorporated your feedback and Thomas's contributions and re-rolled the\nseries.\n\nThomas, thank you for helping out on this series.\n\nMore information in each patch.\n\nj.\n\nJay Soffian (3):\n  send-email: allow send-email to run outside a repo\n  send-email: handle multiple Cc addresses when reading mbox message\n  send-email: --suppress-cc improvements\n\n Documentation/git-send-email.txt |   26 ++++--\n git-send-email.perl              |  183 +++++++++++++++++++++---------------\n t/t9001-send-email.sh            |  192 +++++++++++++++++++++++++++++++++-----\n 3 files changed, 294 insertions(+), 107 deletions(-)\n"},{"id":"104724","messageId":"1234672335-54321-2-git-send-email-jaysoffian@gmail.com","threadId":"17797","inReplyTo":"1234672335-54321-1-git-send-email-jaysoffian@gmail.com","subject":"[PATCH v2 1/3] send-email: allow send-email to run outside a repo","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-15T04:32:13Z","receivedAt":"2009-02-15T04:32:13Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"send-email is supposed to be able to run from outside a repo. This\nability was broken by commits caf0c3d6 (make the message file name more\nspecific) and 5df9fcf6 (interpret unknown files as revision lists).\n\nThis commit provides a fix for both.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\nJunio,\n\nI think you have this one applied already, but I don't currently in next\nnor pu, so I rebased it on next. I also put it first in the series per\nyour request.\n\nj.\n\n git-send-email.perl |   13 +++++++++++--\n 1 files changed, 11 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 77ca8fe..9dad100 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -23,7 +23,7 @@ use Getopt::Long;\n use Text::ParseWords;\n use Data::Dumper;\n use Term::ANSIColor;\n-use File::Temp qw/ tempdir /;\n+use File::Temp qw/ tempdir tempfile /;\n use Error qw(:try);\n use Git;\n \n@@ -156,7 +156,10 @@ if ($@) {\n # Behavior modification variables\n my ($quiet, $dry_run) = (0, 0);\n my $format_patch;\n-my $compose_filename = $repo->repo_path() . \"/.gitsendemail.msg.$$\";\n+my $compose_filename = ($repo ?\n+\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => $repo->repo_path()) :\n+\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => \".\"))[1];\n+\n \n # Handle interactive edition of files.\n my $multiedit;\n@@ -267,6 +270,9 @@ unless ($rc) {\n     usage();\n }\n \n+die \"Cannot run git format-patch from outside a repository\\n\"\n+\tif $format_patch and not $repo;\n+\n # Now, let's fill any that aren't set in with defaults:\n \n sub read_config {\n@@ -404,6 +410,7 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\n \n # returns 1 if the conflict must be solved using it as a format-patch argument\n sub check_file_rev_conflict($) {\n+\treturn unless $repo;\n \tmy $f = shift;\n \ttry {\n \t\t$repo->command('rev-parse', '--verify', '--quiet', $f);\n@@ -445,6 +452,8 @@ while (defined(my $f = shift @ARGV)) {\n }\n \n if (@rev_list_opts) {\n+\tdie \"Cannot run git format-patch from outside a repository\\n\"\n+\t\tunless $repo;\n \tpush @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);\n }\n \n-- \n1.6.2.rc0.251.g344d\n"},{"id":"104725","messageId":"1234672335-54321-3-git-send-email-jaysoffian@gmail.com","threadId":"17797","inReplyTo":"1234672335-54321-2-git-send-email-jaysoffian@gmail.com","subject":"[PATCH v2 2/3] send-email: handle multiple Cc addresses when reading mbox message","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-15T04:32:14Z","receivedAt":"2009-02-15T04:32:14Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"When git format-patch is given multiple --cc arguments, it generates a\nCc header that looks like:\n\n Cc: first@example.com,\n     second@example.com,\n     third@example.com\n\nBefore this commit, send-email was unable to handle such a message as it\ndid not handle folded header lines, nor multiple recipients in a Cc\nline.\n\nThis patch:\n\n- Unfolds header lines by pre-processing the header before extracting\n  any of its fields.\n\n- Handles Cc lines with multiple recipients.\n\n- Adds use of Mail::Address if available for splitting Cc line and\n  the \"Who should the emails be sent to?\" prompt\", with fall back to\n  existing split_addrs() function.\n\n- Tests the new functionality and adds two tests for detecting whether\n  \"From:\" appears correctly in message body when patch author differs\n  from patch sender.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\nChanges from v1:\n\nThe original version of this messed up the logic about when to put a\n\"From:\" in the message body. I fixed that and added two tests to make\nsure it is right.\n\nj.\n\n git-send-email.perl   |  153 +++++++++++++++++++++++++++---------------------\n t/t9001-send-email.sh |   44 ++++++++++++--\n 2 files changed, 123 insertions(+), 74 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 9dad100..a6efd1f 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -126,6 +126,7 @@ sub format_2822_time {\n }\n \n my $have_email_valid = eval { require Email::Valid; 1 };\n+my $have_mail_address = eval { require Mail::Address; 1 };\n my $smtp;\n my $auth;\n \n@@ -366,6 +367,14 @@ foreach my $entry (@bcclist) {\n \tdie \"Comma in --bcclist entry: $entry'\\n\" unless $entry !~ m/,/;\n }\n \n+sub parse_address_line {\n+\tif ($have_mail_address) {\n+\t\treturn map { $_->format } Mail::Address->parse($_[0]);\n+\t} else {\n+\t\treturn split_addrs($_[0]);\n+\t}\n+}\n+\n sub split_addrs {\n \treturn quotewords('\\s*,\\s*', 1, @_);\n }\n@@ -602,7 +611,7 @@ if (!@to) {\n \t}\n \n \tmy $to = $_;\n-\tpush @to, split_addrs($to);\n+\tpush @to, parse_address_line($to);\n \t$prompting++;\n }\n \n@@ -929,88 +938,98 @@ foreach my $t (@files) {\n \t@cc = @initial_cc;\n \t@xh = ();\n \tmy $input_format = undef;\n-\tmy $header_done = 0;\n+\tmy @header = ();\n \t$message = \"\";\n+\t# First unfold multiline header fields\n \twhile(<F>) {\n-\t\tif (!$header_done) {\n-\t\t\tif (/^From /) {\n-\t\t\t\t$input_format = 'mbox';\n-\t\t\t\tnext;\n+\t\tlast if /^\\s*$/;\n+\t\tif (/^\\s+\\S/ and @header) {\n+\t\t\tchomp($header[$#header]);\n+\t\t\ts/^\\s+/ /;\n+\t\t\t$header[$#header] .= $_;\n+\t    } else {\n+\t\t\tpush(@header, $_);\n+\t\t}\n+\t}\n+\t# Now parse the header\n+\tforeach(@header) {\n+\t\tif (/^From /) {\n+\t\t\t$input_format = 'mbox';\n+\t\t\tnext;\n+\t\t}\n+\t\tchomp;\n+\t\tif (!defined $input_format && /^[-A-Za-z]+:\\s/) {\n+\t\t\t$input_format = 'mbox';\n+\t\t}\n+\n+\t\tif (defined $input_format && $input_format eq 'mbox') {\n+\t\t\tif (/^Subject:\\s+(.*)$/) {\n+\t\t\t\t$subject = $1;\n \t\t\t}\n-\t\t\tchomp;\n-\t\t\tif (!defined $input_format && /^[-A-Za-z]+:\\s/) {\n-\t\t\t\t$input_format = 'mbox';\n+\t\t\telsif (/^From:\\s+(.*)$/) {\n+\t\t\t\t($author, $author_encoding) = unquote_rfc2047($1);\n+\t\t\t\tnext if $suppress_cc{'author'};\n+\t\t\t\tnext if $suppress_cc{'self'} and $author eq $sender;\n+\t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\t\t$1, $_) unless $quiet;\n+\t\t\t\tpush @cc, $1;\n \t\t\t}\n-\n-\t\t\tif (defined $input_format && $input_format eq 'mbox') {\n-\t\t\t\tif (/^Subject:\\s+(.*)$/) {\n-\t\t\t\t\t$subject = $1;\n-\n-\t\t\t\t} elsif (/^(Cc|From):\\s+(.*)$/) {\n-\t\t\t\t\tif (unquote_rfc2047($2) eq $sender) {\n+\t\t\telsif (/^Cc:\\s+(.*)$/) {\n+\t\t\t\tforeach my $addr (parse_address_line($1)) {\n+\t\t\t\t\tif (unquote_rfc2047($addr) eq $sender) {\n \t\t\t\t\t\tnext if ($suppress_cc{'self'});\n-\t\t\t\t\t}\n-\t\t\t\t\telsif ($1 eq 'From') {\n-\t\t\t\t\t\t($author, $author_encoding)\n-\t\t\t\t\t\t  = unquote_rfc2047($2);\n-\t\t\t\t\t\tnext if ($suppress_cc{'author'});\n \t\t\t\t\t} else {\n \t\t\t\t\t\tnext if ($suppress_cc{'cc'});\n \t\t\t\t\t}\n \t\t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n-\t\t\t\t\t\t$2, $_) unless $quiet;\n-\t\t\t\t\tpush @cc, $2;\n+\t\t\t\t\t\t$addr, $_) unless $quiet;\n+\t\t\t\t\tpush @cc, $addr;\n \t\t\t\t}\n-\t\t\t\telsif (/^Content-type:/i) {\n-\t\t\t\t\t$has_content_type = 1;\n-\t\t\t\t\tif (/charset=\"?([^ \"]+)/) {\n-\t\t\t\t\t\t$body_encoding = $1;\n-\t\t\t\t\t}\n-\t\t\t\t\tpush @xh, $_;\n-\t\t\t\t}\n-\t\t\t\telsif (/^Message-Id: (.*)/i) {\n-\t\t\t\t\t$message_id = $1;\n-\t\t\t\t}\n-\t\t\t\telsif (!/^Date:\\s/ && /^[-A-Za-z]+:\\s+\\S/) {\n-\t\t\t\t\tpush @xh, $_;\n-\t\t\t\t}\n-\n-\t\t\t} else {\n-\t\t\t\t# In the traditional\n-\t\t\t\t# \"send lots of email\" format,\n-\t\t\t\t# line 1 = cc\n-\t\t\t\t# line 2 = subject\n-\t\t\t\t# So let's support that, too.\n-\t\t\t\t$input_format = 'lots';\n-\t\t\t\tif (@cc == 0 && !$suppress_cc{'cc'}) {\n-\t\t\t\t\tprintf(\"(non-mbox) Adding cc: %s from line '%s'\\n\",\n-\t\t\t\t\t\t$_, $_) unless $quiet;\n-\n-\t\t\t\t\tpush @cc, $_;\n-\n-\t\t\t\t} elsif (!defined $subject) {\n-\t\t\t\t\t$subject = $_;\n+\t\t\t}\n+\t\t\telsif (/^Content-type:/i) {\n+\t\t\t\t$has_content_type = 1;\n+\t\t\t\tif (/charset=\"?([^ \"]+)/) {\n+\t\t\t\t\t$body_encoding = $1;\n \t\t\t\t}\n+\t\t\t\tpush @xh, $_;\n \t\t\t}\n-\n-\t\t\t# A whitespace line will terminate the headers\n-\t\t\tif (m/^\\s*$/) {\n-\t\t\t\t$header_done = 1;\n+\t\t\telsif (/^Message-Id: (.*)/i) {\n+\t\t\t\t$message_id = $1;\n \t\t\t}\n+\t\t\telsif (!/^Date:\\s/ && /^[-A-Za-z]+:\\s+\\S/) {\n+\t\t\t\tpush @xh, $_;\n+\t\t\t}\n+\n \t\t} else {\n-\t\t\t$message .=  $_;\n-\t\t\tif (/^(Signed-off-by|Cc): (.*)$/i) {\n-\t\t\t\tnext if ($suppress_cc{'sob'});\n-\t\t\t\tchomp;\n-\t\t\t\tmy $c = $2;\n-\t\t\t\tchomp $c;\n-\t\t\t\tnext if ($c eq $sender and $suppress_cc{'self'});\n-\t\t\t\tpush @cc, $c;\n-\t\t\t\tprintf(\"(sob) Adding cc: %s from line '%s'\\n\",\n-\t\t\t\t\t$c, $_) unless $quiet;\n+\t\t\t# In the traditional\n+\t\t\t# \"send lots of email\" format,\n+\t\t\t# line 1 = cc\n+\t\t\t# line 2 = subject\n+\t\t\t# So let's support that, too.\n+\t\t\t$input_format = 'lots';\n+\t\t\tif (@cc == 0 && !$suppress_cc{'cc'}) {\n+\t\t\t\tprintf(\"(non-mbox) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\t\t$_, $_) unless $quiet;\n+\t\t\t\tpush @cc, $_;\n+\t\t\t} elsif (!defined $subject) {\n+\t\t\t\t$subject = $_;\n \t\t\t}\n \t\t}\n \t}\n+\t# Now parse the message body\n+\twhile(<F>) {\n+\t\t$message .=  $_;\n+\t\tif (/^(Signed-off-by|Cc): (.*)$/i) {\n+\t\t\tnext if ($suppress_cc{'sob'});\n+\t\t\tchomp;\n+\t\t\tmy $c = $2;\n+\t\t\tchomp $c;\n+\t\t\tnext if ($c eq $sender and $suppress_cc{'self'});\n+\t\t\tpush @cc, $c;\n+\t\t\tprintf(\"(sob) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\t$c, $_) unless $quiet;\n+\t\t}\n+\t}\n \tclose F;\n \n \tif (defined $cc_cmd && !$suppress_cc{'cccmd'}) {\n@@ -1029,7 +1048,7 @@ foreach my $t (@files) {\n \t\t\tor die \"(cc-cmd) failed to close pipe to '$cc_cmd'\";\n \t}\n \n-\tif (defined $author) {\n+\tif (defined $author and $author ne $sender) {\n \t\t$message = \"From: $author\\n\\n$message\";\n \t\tif (defined $author_encoding) {\n \t\t\tif ($has_content_type) {\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex cb3d183..63ab88b 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -32,7 +32,7 @@ clean_fake_sendmail() {\n }\n \n test_expect_success 'Extract patches' '\n-    patches=`git format-patch -n HEAD^1`\n+    patches=`git format-patch --cc=\"One <one@example.com>\" --cc=two@example.com -n HEAD^1`\n '\n \n test_expect_success 'Send patches' '\n@@ -42,6 +42,8 @@ test_expect_success 'Send patches' '\n cat >expected <<\\EOF\n !nobody@example.com!\n !author@example.com!\n+!one@example.com!\n+!two@example.com!\n EOF\n test_expect_success \\\n     'Verify commandline' \\\n@@ -50,13 +52,15 @@ test_expect_success \\\n cat >expected-show-all-headers <<\\EOF\n 0001-Second.patch\n (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'\n+(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'\n Dry-OK. Log says:\n Server: relay.example.com\n MAIL FROM:<from@example.com>\n-RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<bcc@example.com>\n+RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<bcc@example.com>\n From: Example <from@example.com>\n To: to@example.com\n-Cc: cc@example.com, A <author@example.com>\n+Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com\n Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n@@ -104,6 +108,28 @@ test_expect_success 'no patch was sent' '\n \t! test -e commandline1\n '\n \n+test_expect_success 'Author From: in message body' '\n+\tclean_fake_sendmail &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t$patches &&\n+\tsed \"1,/^$/d\" < msgtxt1 > msgbody1\n+\tgrep \"From: A <author@example.com>\" msgbody1\n+'\n+\n+test_expect_success 'Author From: not in message body' '\n+\tclean_fake_sendmail &&\n+\tgit send-email \\\n+\t\t--from=\"A <author@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t$patches &&\n+\tsed \"1,/^$/d\" < msgtxt1 > msgbody1\n+\t! grep \"From: A <author@example.com>\" msgbody1\n+'\n+\n test_expect_success 'allow long lines with --no-validate' '\n \tgit send-email \\\n \t\t--from=\"Example <nobody@example.com>\" \\\n@@ -170,13 +196,15 @@ test_expect_success 'second message is patch' '\n cat >expected-show-all-headers <<\\EOF\n 0001-Second.patch\n (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'\n+(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'\n Dry-OK. Log says:\n Server: relay.example.com\n MAIL FROM:<from@example.com>\n-RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>\n+RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>,<one@example.com>,<two@example.com>\n From: Example <from@example.com>\n To: to@example.com\n-Cc: cc@example.com, A <author@example.com>\n+Cc: cc@example.com, A <author@example.com>, One <one@example.com>, two@example.com\n Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n@@ -203,13 +231,15 @@ test_expect_success 'sendemail.cc set' '\n cat >expected-show-all-headers <<\\EOF\n 0001-Second.patch\n (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'\n+(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'\n Dry-OK. Log says:\n Server: relay.example.com\n MAIL FROM:<from@example.com>\n-RCPT TO:<to@example.com>,<author@example.com>\n+RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>\n From: Example <from@example.com>\n To: to@example.com\n-Cc: A <author@example.com>\n+Cc: A <author@example.com>, One <one@example.com>, two@example.com\n Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n-- \n1.6.2.rc0.251.g344d\n"},{"id":"104726","messageId":"1234672335-54321-4-git-send-email-jaysoffian@gmail.com","threadId":"17797","inReplyTo":"1234672335-54321-3-git-send-email-jaysoffian@gmail.com","subject":"[PATCH v2 3/3] send-email: --suppress-cc improvements","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-15T04:32:15Z","receivedAt":"2009-02-15T04:32:15Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Since 6564828 (git-send-email: Generalize auto-cc recipient\nmechanism., 2007-12-25) we can suppress automatic Cc generation\nseparately for each of the possible address sources.  However,\n--suppress-cc=sob suppressed both SOB lines and body (but not header)\nCc lines, contrary to the name.\n\nChange --suppress-cc=sob to mean only SOB lines, and add separate\nchoices 'bodycc' (body Cc lines) and 'body' (both 'sob' and 'bodycc').\nThe option --no-signed-off-by-cc now acts like --suppress-cc=sob,\nwhich is not backwards compatible but matches the name of the option.\n\nAlso update the documentation and add a few tests.\n\nOriginal patch by me. Revised by Thomas Rast, who contributed the\ndocumentation and test updates.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\nChanges from v1:\n\nI incorporated Thomas's changes, which were per your suggestions.\nThomas, thank you for the contribution.\n\nI also agreed that self is special, and --suppress-cc=cc should keep\nself in a header Cc. The user can always use --suppress-cc=self in\naddition to --suppress-cc=cc if they want. For consistency, I made\n--suppress-cc={ccbody,sob} keep self as well. I updated the\ndocumentation to clarify this.\n\nj.\n\n Documentation/git-send-email.txt |   27 +++++--\n git-send-email.perl              |   28 +++++--\n t/t9001-send-email.sh            |  150 +++++++++++++++++++++++++++++++++-----\n 3 files changed, 169 insertions(+), 36 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex ff4aeff..164d149 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -164,14 +164,25 @@ Automating\n \n --suppress-cc::\n \tSpecify an additional category of recipients to suppress the\n-\tauto-cc of.  'self' will avoid including the sender, 'author' will\n-\tavoid including the patch author, 'cc' will avoid including anyone\n-\tmentioned in Cc lines in the patch, 'sob' will avoid including\n-\tanyone mentioned in Signed-off-by lines, and 'cccmd' will avoid\n-\trunning the --cc-cmd.  'all' will suppress all auto cc values.\n-\tDefault is the value of 'sendemail.suppresscc' configuration value;\n-\tif that is unspecified, default to 'self' if --suppress-from is\n-\tspecified, as well as 'sob' if --no-signed-off-cc is specified.\n+\tauto-cc of:\n++\n+--\n+- 'author' will avoid including the patch author\n+- 'self' will avoid including the sender\n+- 'cc' will avoid including anyone mentioned in Cc lines in the patch header\n+  except for self (use 'self' for that).\n+- 'ccbody' will avoid including anyone mentioned in Cc lines in the\n+  patch body (commit message) except for self (use 'self' for that).\n+- 'sob' will avoid including anyone mentioned in Signed-off-by lines except\n+   for self (use 'self' for that).\n+- 'cccmd' will avoid running the --cc-cmd.\n+- 'body' is equivalent to 'sob' + 'ccbody'\n+- 'all' will suppress all auto cc values.\n+--\n++\n+Default is the value of 'sendemail.suppresscc' configuration value; if\n+that is unspecified, default to 'self' if --suppress-from is\n+specified, as well as 'body' if --no-signed-off-cc is specified.\n \n --[no-]suppress-from::\n \tIf this is set, do not add the From: address to the cc: list.\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex a6efd1f..54e7617 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -68,9 +68,8 @@ git send-email [options] <file | directory | rev-list options >\n   Automating:\n     --identity              <str>  * Use the sendemail.<id> options.\n     --cc-cmd                <str>  * Email Cc: via `<str> \\$patch_path`\n-    --suppress-cc           <str>  * author, self, sob, cccmd, all.\n-    --[no-]signed-off-by-cc        * Send to Cc: and Signed-off-by:\n-                                     addresses. Default on.\n+    --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, all.\n+    --[no-]signed-off-by-cc        * Send to Signed-off-by: addresses. Default on.\n     --[no-]suppress-from           * Send to self. Default off.\n     --[no-]chain-reply-to          * Chain In-Reply-To: fields. Default on.\n     --[no-]thread                  * Use In-Reply-To: field. Default on.\n@@ -325,13 +324,13 @@ my(%suppress_cc);\n if (@suppress_cc) {\n \tforeach my $entry (@suppress_cc) {\n \t\tdie \"Unknown --suppress-cc field: '$entry'\\n\"\n-\t\t\tunless $entry =~ /^(all|cccmd|cc|author|self|sob)$/;\n+\t\t\tunless $entry =~ /^(all|cccmd|cc|author|self|sob|body|bodycc)$/;\n \t\t$suppress_cc{$entry} = 1;\n \t}\n }\n \n if ($suppress_cc{'all'}) {\n-\tforeach my $entry (qw (ccmd cc author self sob)) {\n+\tforeach my $entry (qw (ccmd cc author self sob body bodycc)) {\n \t\t$suppress_cc{$entry} = 1;\n \t}\n \tdelete $suppress_cc{'all'};\n@@ -341,6 +340,13 @@ if ($suppress_cc{'all'}) {\n $suppress_cc{'self'} = $suppress_from if defined $suppress_from;\n $suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc;\n \n+if ($suppress_cc{'body'}) {\n+\tforeach my $entry (qw (sob bodycc)) {\n+\t\t$suppress_cc{$entry} = 1;\n+\t}\n+\tdelete $suppress_cc{'body'};\n+}\n+\n # Debugging, print out the suppressions.\n if (0) {\n \tprint \"suppressions:\\n\";\n@@ -1020,13 +1026,17 @@ foreach my $t (@files) {\n \twhile(<F>) {\n \t\t$message .=  $_;\n \t\tif (/^(Signed-off-by|Cc): (.*)$/i) {\n-\t\t\tnext if ($suppress_cc{'sob'});\n \t\t\tchomp;\n-\t\t\tmy $c = $2;\n+\t\t\tmy ($what, $c) = ($1, $2);\n \t\t\tchomp $c;\n-\t\t\tnext if ($c eq $sender and $suppress_cc{'self'});\n+\t\t\tif ($c eq $sender) {\n+\t\t\t\tnext if ($suppress_cc{'self'});\n+\t\t\t} else {\n+\t\t\t\tnext if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;\n+\t\t\t\tnext if $suppress_cc{'bodycc'} and $what =~ /Cc/i;\n+\t\t\t}\n \t\t\tpush @cc, $c;\n-\t\t\tprintf(\"(sob) Adding cc: %s from line '%s'\\n\",\n+\t\t\tprintf(\"(body) Adding cc: %s from line '%s'\\n\",\n \t\t\t\t$c, $_) unless $quiet;\n \t\t}\n \t}\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 63ab88b..4df4f96 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -32,11 +32,11 @@ clean_fake_sendmail() {\n }\n \n test_expect_success 'Extract patches' '\n-    patches=`git format-patch --cc=\"One <one@example.com>\" --cc=two@example.com -n HEAD^1`\n+    patches=`git format-patch -s --cc=\"One <one@example.com>\" --cc=two@example.com -n HEAD^1`\n '\n \n test_expect_success 'Send patches' '\n-     git send-email --from=\"Example <nobody@example.com>\" --to=nobody@example.com --smtp-server=\"$(pwd)/fake.sendmail\" $patches 2>errors\n+     git send-email --suppress-cc=sob --from=\"Example <nobody@example.com>\" --to=nobody@example.com --smtp-server=\"$(pwd)/fake.sendmail\" $patches 2>errors\n '\n \n cat >expected <<\\EOF\n@@ -74,6 +74,7 @@ EOF\n test_expect_success 'Show all headers' '\n \tgit send-email \\\n \t\t--dry-run \\\n+\t\t--suppress-cc=sob \\\n \t\t--from=\"Example <from@example.com>\" \\\n \t\t--to=to@example.com \\\n \t\t--cc=cc@example.com \\\n@@ -193,7 +194,7 @@ test_expect_success 'second message is patch' '\n \tgrep \"Subject:.*Second\" msgtxt2\n '\n \n-cat >expected-show-all-headers <<\\EOF\n+cat >expected-suppress-sob <<\\EOF\n 0001-Second.patch\n (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'\n@@ -213,10 +214,10 @@ X-Mailer: X-MAILER-STRING\n Result: OK\n EOF\n \n-test_expect_success 'sendemail.cc set' '\n-\tgit config sendemail.cc cc@example.com &&\n+test_suppression () {\n \tgit send-email \\\n \t\t--dry-run \\\n+\t\t--suppress-cc=$1 \\\n \t\t--from=\"Example <from@example.com>\" \\\n \t\t--to=to@example.com \\\n \t\t--smtp-server relay.example.com \\\n@@ -224,11 +225,16 @@ test_expect_success 'sendemail.cc set' '\n \tsed\t-e \"s/^\\(Date:\\).*/\\1 DATE-STRING/\" \\\n \t\t-e \"s/^\\(Message-Id:\\).*/\\1 MESSAGE-ID-STRING/\" \\\n \t\t-e \"s/^\\(X-Mailer:\\).*/\\1 X-MAILER-STRING/\" \\\n-\t\t>actual-show-all-headers &&\n-\ttest_cmp expected-show-all-headers actual-show-all-headers\n+\t\t>actual-suppress-$1 &&\n+\ttest_cmp expected-suppress-$1 actual-suppress-$1\n+}\n+\n+test_expect_success 'sendemail.cc set' '\n+\tgit config sendemail.cc cc@example.com &&\n+\ttest_suppression sob\n '\n \n-cat >expected-show-all-headers <<\\EOF\n+cat >expected-suppress-sob <<\\EOF\n 0001-Second.patch\n (mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n (mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'\n@@ -250,17 +256,123 @@ EOF\n \n test_expect_success 'sendemail.cc unset' '\n \tgit config --unset sendemail.cc &&\n-\tgit send-email \\\n-\t\t--dry-run \\\n-\t\t--from=\"Example <from@example.com>\" \\\n-\t\t--to=to@example.com \\\n-\t\t--smtp-server relay.example.com \\\n-\t\t$patches |\n-\tsed\t-e \"s/^\\(Date:\\).*/\\1 DATE-STRING/\" \\\n-\t\t-e \"s/^\\(Message-Id:\\).*/\\1 MESSAGE-ID-STRING/\" \\\n-\t\t-e \"s/^\\(X-Mailer:\\).*/\\1 X-MAILER-STRING/\" \\\n-\t\t>actual-show-all-headers &&\n-\ttest_cmp expected-show-all-headers actual-show-all-headers\n+\ttest_suppression sob\n+'\n+\n+cat >expected-suppress-all <<\\EOF\n+0001-Second.patch\n+Dry-OK. Log says:\n+Server: relay.example.com\n+MAIL FROM:<from@example.com>\n+RCPT TO:<to@example.com>\n+From: Example <from@example.com>\n+To: to@example.com\n+Subject: [PATCH 1/1] Second.\n+Date: DATE-STRING\n+Message-Id: MESSAGE-ID-STRING\n+X-Mailer: X-MAILER-STRING\n+\n+Result: OK\n+EOF\n+\n+test_expect_success '--suppress-cc=all' '\n+\ttest_suppression all\n+'\n+\n+cat >expected-suppress-body <<\\EOF\n+0001-Second.patch\n+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'\n+(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'\n+Dry-OK. Log says:\n+Server: relay.example.com\n+MAIL FROM:<from@example.com>\n+RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>\n+From: Example <from@example.com>\n+To: to@example.com\n+Cc: A <author@example.com>, One <one@example.com>, two@example.com\n+Subject: [PATCH 1/1] Second.\n+Date: DATE-STRING\n+Message-Id: MESSAGE-ID-STRING\n+X-Mailer: X-MAILER-STRING\n+\n+Result: OK\n+EOF\n+\n+test_expect_success '--suppress-cc=body' '\n+\ttest_suppression body\n+'\n+\n+cat >expected-suppress-sob <<\\EOF\n+0001-Second.patch\n+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'\n+(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'\n+Dry-OK. Log says:\n+Server: relay.example.com\n+MAIL FROM:<from@example.com>\n+RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>\n+From: Example <from@example.com>\n+To: to@example.com\n+Cc: A <author@example.com>, One <one@example.com>, two@example.com\n+Subject: [PATCH 1/1] Second.\n+Date: DATE-STRING\n+Message-Id: MESSAGE-ID-STRING\n+X-Mailer: X-MAILER-STRING\n+\n+Result: OK\n+EOF\n+\n+test_expect_success '--suppress-cc=sob' '\n+\ttest_suppression sob\n+'\n+\n+cat >expected-suppress-bodycc <<\\EOF\n+0001-Second.patch\n+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+(mbox) Adding cc: One <one@example.com> from line 'Cc: One <one@example.com>, two@example.com'\n+(mbox) Adding cc: two@example.com from line 'Cc: One <one@example.com>, two@example.com'\n+(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'\n+Dry-OK. Log says:\n+Server: relay.example.com\n+MAIL FROM:<from@example.com>\n+RCPT TO:<to@example.com>,<author@example.com>,<one@example.com>,<two@example.com>,<committer@example.com>\n+From: Example <from@example.com>\n+To: to@example.com\n+Cc: A <author@example.com>, One <one@example.com>, two@example.com, C O Mitter <committer@example.com>\n+Subject: [PATCH 1/1] Second.\n+Date: DATE-STRING\n+Message-Id: MESSAGE-ID-STRING\n+X-Mailer: X-MAILER-STRING\n+\n+Result: OK\n+EOF\n+\n+test_expect_success '--suppress-cc=bodycc' '\n+\ttest_suppression bodycc\n+'\n+\n+cat >expected-suppress-cc <<\\EOF\n+0001-Second.patch\n+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'\n+(body) Adding cc: C O Mitter <committer@example.com> from line 'Signed-off-by: C O Mitter <committer@example.com>'\n+Dry-OK. Log says:\n+Server: relay.example.com\n+MAIL FROM:<from@example.com>\n+RCPT TO:<to@example.com>,<author@example.com>,<committer@example.com>\n+From: Example <from@example.com>\n+To: to@example.com\n+Cc: A <author@example.com>, C O Mitter <committer@example.com>\n+Subject: [PATCH 1/1] Second.\n+Date: DATE-STRING\n+Message-Id: MESSAGE-ID-STRING\n+X-Mailer: X-MAILER-STRING\n+\n+Result: OK\n+EOF\n+\n+test_expect_success '--suppress-cc=cc' '\n+\ttest_suppression cc\n '\n \n test_expect_success '--compose adds MIME for utf8 body' '\n-- \n1.6.2.rc0.251.g344d\n"},{"id":"104727","messageId":"20090215050731.GA32067@kroah.com","threadId":"17797","inReplyTo":"1234672335-54321-3-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH v2 2/3] send-email: handle multiple Cc addresses when reading mbox message","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2009-02-15T05:07:31Z","receivedAt":"2009-02-15T05:07:31Z","isPatch":true,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Sat, Feb 14, 2009 at 11:32:14PM -0500, Jay Soffian wrote:\n> When git format-patch is given multiple --cc arguments, it generates a\n> Cc header that looks like:\n> \n>  Cc: first@example.com,\n>      second@example.com,\n>      third@example.com\n> \n> Before this commit, send-email was unable to handle such a message as it\n> did not handle folded header lines, nor multiple recipients in a Cc\n> line.\n> \n> This patch:\n> \n> - Unfolds header lines by pre-processing the header before extracting\n>   any of its fields.\n> \n> - Handles Cc lines with multiple recipients.\n> \n> - Adds use of Mail::Address if available for splitting Cc line and\n>   the \"Who should the emails be sent to?\" prompt\", with fall back to\n>   existing split_addrs() function.\n\nYES!!!\n\nI was just trying to fix this in the latest version, as it couldn't\nhandle mbox files well at all (vger.kernel.org spit the output back at\nme quite nastily when I tried it.)\n\nThanks for these fixes, I personally really appreciate it, and need\nthem.\n\ngreg k-h\n"}]}