{"thread":{"id":"25265","subject":"[PATCH] send-email: Use To: headers in patch files","startedAt":"2010-09-28T08:02:44Z","lastAt":"2010-09-29T07:26:44Z","messageCount":3,"participants":["Stephen Boyd","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"151882","messageId":"1285660964-26758-1-git-send-email-bebarino@gmail.com","threadId":"25265","inReplyTo":null,"subject":"[PATCH] send-email: Use To: headers in patch files","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2010-09-28T08:02:44Z","receivedAt":"2010-09-28T08:02:44Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"It's a minor annoyance when you take the painstaking time to setup To:\nheaders for each patch in a large series, and then go out to send the\nseries with git-send-email and watch git ignore the To: headers in the\npatch files.\n\nTherefore, always add To: headers from a patch file to the To: headers\nfor that message. Keep the prompt for the blanket To: header so as to\nnot break scripts (and user expectations). This means even if a patch\nhas a To: header, git will prompt for the To: address. Otherwise, we'll\nneed to introduce interface breakage to either request the header for\neach patch missing a To: header or default the header to whatever To:\naddress is found first (be it in a patch or from user input). Both of\nthese options don't seem very obvious/useful.\n\nReported-by: Viresh Kumar <viresh.kumar@st.com>\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\nTested-by: Viresh Kumar <viresh.kumar@st.com>\n---\n\nThis is a resend of a patch a few weeks ago with some added tests.\n\n git-send-email.perl   |    7 +++++++\n t/t9001-send-email.sh |   22 ++++++++++++++++++++++\n 2 files changed, 29 insertions(+), 0 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e1f29a7..d6028ec 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1176,6 +1176,13 @@ foreach my $t (@files) {\n \t\t\t\t\t$1, $_) unless $quiet;\n \t\t\t\tpush @cc, $1;\n \t\t\t}\n+\t\t\telsif (/^To:\\s+(.*)$/) {\n+\t\t\t\tforeach my $addr (parse_address_line($1)) {\n+\t\t\t\t\tprintf(\"(mbox) Adding to: %s from line '%s'\\n\",\n+\t\t\t\t\t\t$addr, $_) unless $quiet;\n+\t\t\t\t\tpush @to, sanitize_address($addr);\n+\t\t\t\t}\n+\t\t\t}\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) {\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 71b3df9..6bd9ea7 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -947,6 +947,28 @@ test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '\n \t! grep \"RCPT TO:<other@ex.com>\" stdout\n '\n \n+test_expect_success $PREREQ 'patches To headers are used by default' '\n+\tpatch=`git format-patch -1 --to=\"bodies@example.com\"` &&\n+\tgit send-email \\\n+\t\t--dry-run \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server relay.example.com \\\n+\t\t$patch >stdout &&\n+\tgrep \"RCPT TO:<bodies@example.com>\" stdout\n+'\n+\n+test_expect_success $PREREQ 'patches To headers are appended to' '\n+\tpatch=`git format-patch -1 --to=\"bodies@example.com\"` &&\n+\tgit send-email \\\n+\t\t--dry-run \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server relay.example.com \\\n+\t\t$patch >stdout &&\n+\tgrep \"RCPT TO:<bodies@example.com>\" stdout &&\n+\tgrep \"RCPT TO:<nobody@example.com>\" stdout\n+'\n+\n test_expect_success $PREREQ 'setup expect' '\n cat >email-using-8bit <<EOF\n From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001\n-- \n1.7.3.16.g5d4d9\n"},{"id":"151914","messageId":"AANLkTimTmfORavF6pNGjC6L46_f+GOaz86jEzBPYUxF2@mail.gmail.com","threadId":"25265","inReplyTo":"1285660964-26758-1-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH] send-email: Use To: headers in patch files","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-09-28T14:34:02Z","receivedAt":"2010-09-28T14:34:02Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, Sep 28, 2010 at 08:02, Stephen Boyd <bebarino@gmail.com> wrote:\n\n> +test_expect_success $PREREQ 'patches To headers are used by default' '\n> +       patch=`git format-patch -1 --to=\"bodies@example.com\"` &&\n> +       git send-email \\\n> +               --dry-run \\\n> +               --from=\"Example <nobody@example.com>\" \\\n> +               --smtp-server relay.example.com \\\n> +               $patch >stdout &&\n> +       grep \"RCPT TO:<bodies@example.com>\" stdout\n> +'\n\nWhy not:\n\n    git format-patch -1 --to=\"bodies@example.com\" &&\n    test_when_finished \"rm *.patch\" &&\n    git send-email [...] *.patch >out &&\n    [...]\n"},{"id":"152025","messageId":"1285745204-22443-1-git-send-email-bebarino@gmail.com","threadId":"25265","inReplyTo":"AANLkTimTmfORavF6pNGjC6L46_f+GOaz86jEzBPYUxF2@mail.gmail.com","subject":"[PATCHv2] send-email: Use To: headers in patch files","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2010-09-29T07:26:44Z","receivedAt":"2010-09-29T07:26:44Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"It's a minor annoyance when you take the painstaking time to setup To:\nheaders for each patch in a large series, and then go out to send the\nseries with git-send-email and watch git ignore the To: headers in the\npatch files.\n\nTherefore, always add To: headers from a patch file to the To: headers\nfor that message. Keep the prompt for the blanket To: header so as to\nnot break scripts (and user expectations). This means even if a patch\nhas a To: header, git will prompt for the To: address. Otherwise, we'll\nneed to introduce interface breakage to either request the header for\neach patch missing a To: header or default the header to whatever To:\naddress is found first (be it in a patch or from user input). Both of\nthese options don't seem very obvious/useful.\n\nReported-by: Viresh Kumar <viresh.kumar@st.com>\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\nTested-by: Viresh Kumar <viresh.kumar@st.com>\n---\n\nChanges since v1:\n - Added test_when_finished calls.\n\n git-send-email.perl   |    7 +++++++\n t/t9001-send-email.sh |   24 ++++++++++++++++++++++++\n 2 files changed, 31 insertions(+), 0 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e1f29a7..d6028ec 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1176,6 +1176,13 @@ foreach my $t (@files) {\n \t\t\t\t\t$1, $_) unless $quiet;\n \t\t\t\tpush @cc, $1;\n \t\t\t}\n+\t\t\telsif (/^To:\\s+(.*)$/) {\n+\t\t\t\tforeach my $addr (parse_address_line($1)) {\n+\t\t\t\t\tprintf(\"(mbox) Adding to: %s from line '%s'\\n\",\n+\t\t\t\t\t\t$addr, $_) unless $quiet;\n+\t\t\t\t\tpush @to, sanitize_address($addr);\n+\t\t\t\t}\n+\t\t\t}\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) {\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 71b3df9..294e31f 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -947,6 +947,30 @@ test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '\n \t! grep \"RCPT TO:<other@ex.com>\" stdout\n '\n \n+test_expect_success $PREREQ 'patches To headers are used by default' '\n+\tpatch=`git format-patch -1 --to=\"bodies@example.com\"` &&\n+\ttest_when_finished \"rm $patch\" &&\n+\tgit send-email \\\n+\t\t--dry-run \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--smtp-server relay.example.com \\\n+\t\t$patch >stdout &&\n+\tgrep \"RCPT TO:<bodies@example.com>\" stdout\n+'\n+\n+test_expect_success $PREREQ 'patches To headers are appended to' '\n+\tpatch=`git format-patch -1 --to=\"bodies@example.com\"` &&\n+\ttest_when_finished \"rm $patch\" &&\n+\tgit send-email \\\n+\t\t--dry-run \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server relay.example.com \\\n+\t\t$patch >stdout &&\n+\tgrep \"RCPT TO:<bodies@example.com>\" stdout &&\n+\tgrep \"RCPT TO:<nobody@example.com>\" stdout\n+'\n+\n test_expect_success $PREREQ 'setup expect' '\n cat >email-using-8bit <<EOF\n From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001\n-- \n1.7.3.16.g5d4d9\n"}]}