@matheusbsbs / matheus-bagliano / commits / 21802cd328
Fork 0

send-email: Use To: headers in patch files

It's a minor annoyance when you take the painstaking time to setup To: headers for each patch in a large series, and then go out to send the series with git-send-email and watch git ignore the To: headers in the patch files. Therefore, always add To: headers from a patch file to the To: headers for that message. Keep the prompt for the blanket To: header so as to not break scripts (and user expectations). This means even if a patch has a To: header, git will prompt for the To: address. Otherwise, we'll need to introduce interface breakage to either request the header for each patch missing a To: header or default the header to whatever To: address is found first (be it in a patch or from user input). Both of these options don't seem very obvious/useful. Reported-by: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Stephen Boyd <bebarino@gmail.com> Tested-by: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Sep 29, 2010 at 00:26 UTC 21802cd32805b19fa32e8e3594ee3914733d53d3
2 files changed +31
git-send-email.perl
+7
@@ -1176,6 +1176,13 @@ foreach my $t (@files) {
1176 $1, $_) unless $quiet;
1177 push @cc, $1;
1178 }
1179 + elsif (/^To:\s+(.*)$/) {
1180 + foreach my $addr (parse_address_line($1)) {
1181 + printf("(mbox) Adding to: %s from line '%s'\n",
1182 + $addr, $_) unless $quiet;
1183 + push @to, sanitize_address($addr);
1184 + }
1185 + }
1186 elsif (/^Cc:\s+(.*)$/) {
1187 foreach my $addr (parse_address_line($1)) {
1188 if (unquote_rfc2047($addr) eq $sender) {
t/t9001-send-email.sh
+24
@@ -947,6 +947,30 @@ test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
947 ! grep "RCPT TO:<other@ex.com>" stdout
948 '
949
950 +test_expect_success $PREREQ 'patches To headers are used by default' '
951 + patch=`git format-patch -1 --to="bodies@example.com"` &&
952 + test_when_finished "rm $patch" &&
953 + git send-email \
954 + --dry-run \
955 + --from="Example <nobody@example.com>" \
956 + --smtp-server relay.example.com \
957 + $patch >stdout &&
958 + grep "RCPT TO:<bodies@example.com>" stdout
959 +'
960 +
961 +test_expect_success $PREREQ 'patches To headers are appended to' '
962 + patch=`git format-patch -1 --to="bodies@example.com"` &&
963 + test_when_finished "rm $patch" &&
964 + git send-email \
965 + --dry-run \
966 + --from="Example <nobody@example.com>" \
967 + --to=nobody@example.com \
968 + --smtp-server relay.example.com \
969 + $patch >stdout &&
970 + grep "RCPT TO:<bodies@example.com>" stdout &&
971 + grep "RCPT TO:<nobody@example.com>" stdout
972 +'
973 +
974 test_expect_success $PREREQ 'setup expect' '
975 cat >email-using-8bit <<EOF
976 From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001