Skip to contentSkip to conversation

git send-email doesn't take To: addresses from the patch

DISCUSSION viresh kumar 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

I am using git-1.7.2 and use following command to generate a patch

$ git format-patch --to [email protected] HEAD^

Now when I use git send-email to send this patch, it is not taking the
To: embedded in the patch as its destination, instead it asks for one and if not provided it keeps this field empty.
On the other hand git send-email is taking the Cc addresses from the patch perfectly in to account.

How can I use git send-email to pick To: addresses directly from the patch.

regards
Viresh Kumar

#1 lore raw
Quoted 6 lines · viresh kumar

Hi,

I am using git-1.7.2 and use following command to generate a patch

$ git format-patch --to [email protected] HEAD^
Quoted 8 lines

Now when I use git send-email to send this patch, it is not taking the
To: embedded in the patch as its destination, instead it asks for one and if not provided it keeps this field empty.
On the other hand git send-email is taking the Cc addresses from the patch perfectly in to account.

How can I use git send-email to pick To: addresses directly from the patch.

You can't. Nobody has bothered to make git-send-email consider the To: field. Can you try this patch out? I think it will mostly work, except I haven't bothered to look at --compose yet and I'm halfway stumbling through this code right now.

---->8-----

Subject: [PATCH] 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.

---
 git-send-email.perl |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
git-send-email.perl +7 -0
index 6dab3bf..06373ed 100755
@@ -1176,6 +1176,13 @@ foreach my $t (@files) {
 					$1, $_) unless $quiet;
 				push @cc, $1;
 			}
+			elsif (/^To:\s+(.*)$/) {
+				foreach my $addr (parse_address_line($1)) {
+					printf("(mbox) Adding to: %s from line '%s'\n",
+						$addr, $_) unless $quiet;
+					push @to, sanitize_address($addr);
+				}
+			}
 			elsif (/^Cc:\s+(.*)$/) {
 				foreach my $addr (parse_address_line($1)) {
 					if (unquote_rfc2047($addr) eq $sender) {
Signature · 1 line
1.7.2.2.178.gd8a94
author Tested-by
#2 lore raw
Quoted 16 lines · Stephen Boyd

Subject: [PATCH] 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.

Quoted 2 lines
#3 lore raw
Quoted 17 lines · viresh kumar
Quoted 16 lines · Stephen Boyd

Subject: [PATCH] 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.

Quoted 5 lines
Quoted 2 lines

Cool. Junio, does this look good to you? I can squash in some tests later tonight if I get some git time.

#4 lore raw
Quoted 2 lines · Stephen Boyd

Cool. Junio, does this look good to you? I can squash in some tests later tonight if I get some git time.

It works perfectly fine for me.

thanks
viresh

#5 lore raw
In reply to Stephen Boyd
Quoted 6 lines · Stephen Boyd
Quoted 2 lines · viresh kumar
Quoted 1 line · Stephen Boyd

Subject: [PATCH] send-email: Use To: headers in patch files

...
Cool. Junio, does this look good to you? I can squash in some tests later tonight if I get some git time.

Sounds sane; thanks.