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

6 messages from 2010-08-30 to 2010-09-03. Participants: viresh kumar, Stephen Boyd, Junio C Hamano.
Thread: https://gitlist.dev/t/24907

## viresh kumar, 2010-08-30 07:05

Subject: git send-email doesn't take To: addresses from the patch
Message-ID: <4C7B5853.7010001@st.com>
URL: https://gitlist.dev/e/4C7B5853.7010001%40st.com

```
Hi,

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

$ git format-patch --to abc@xyz.com 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

```

## Stephen Boyd, 2010-09-01 07:50

Subject: Re: git send-email doesn't take To: addresses from the patch
Message-ID: <4C7E05B5.1050805@gmail.com>
URL: https://gitlist.dev/e/4C7E05B5.1050805%40gmail.com
In-Reply-To: <4C7B5853.7010001@st.com>

```
  On 08/30/2010 12:05 AM, viresh kumar wrote:
> Hi,
>
> I am using git-1.7.2 and use following command to generate a patch
>
> $ git format-patch --to abc@xyz.com 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.

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.

Reported-by: viresh kumar<viresh.kumar@st.com>
Signed-off-by: Stephen Boyd<bebarino@gmail.com>
---
  git-send-email.perl |    7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 6dab3bf..06373ed 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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) {
-- 
1.7.2.2.178.gd8a94

```

## viresh kumar, 2010-09-01 08:56

Subject: Re: git send-email doesn't take To: addresses from the patch
Message-ID: <4C7E1537.9030405@st.com>
URL: https://gitlist.dev/e/4C7E1537.9030405%40st.com
In-Reply-To: <4C7E05B5.1050805@gmail.com>

```
On 9/1/2010 1:20 PM, Stephen Boyd wrote:
> 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.
> 
> Reported-by: viresh kumar<viresh.kumar@st.com>
> Signed-off-by: Stephen Boyd<bebarino@gmail.com>

Tested-by: Viresh Kumar <viresh.kumar@st.com>

```

## Stephen Boyd, 2010-09-02 18:36

Subject: Re: git send-email doesn't take To: addresses from the patch
Message-ID: <AANLkTi=xQAoEFiB2zGz73ZwSwq16LOthkqd7w1GhnEup@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DxQAoEFiB2zGz73ZwSwq16LOthkqd7w1GhnEup%40mail.gmail.com
In-Reply-To: <4C7E1537.9030405@st.com>

```
On Wed, Sep 1, 2010 at 1:56 AM, viresh kumar <viresh.kumar@st.com> wrote:
> On 9/1/2010 1:20 PM, Stephen Boyd wrote:
>> 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.
>>
>> Reported-by: viresh kumar<viresh.kumar@st.com>
>> Signed-off-by: Stephen Boyd<bebarino@gmail.com>
>
> Tested-by: Viresh Kumar <viresh.kumar@st.com>
>

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

```

## viresh kumar, 2010-09-03 04:02

Subject: Re: git send-email doesn't take To: addresses from the patch
Message-ID: <4C80733B.2020406@st.com>
URL: https://gitlist.dev/e/4C80733B.2020406%40st.com
In-Reply-To: <AANLkTi=xQAoEFiB2zGz73ZwSwq16LOthkqd7w1GhnEup@mail.gmail.com>

```
On 9/3/2010 12:06 AM, Stephen Boyd wrote:
> 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

```

## Junio C Hamano, 2010-09-03 17:18

Subject: Re: git send-email doesn't take To: addresses from the patch
Message-ID: <7vk4n2zqxr.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk4n2zqxr.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTi=xQAoEFiB2zGz73ZwSwq16LOthkqd7w1GhnEup@mail.gmail.com>

```
Stephen Boyd <bebarino@gmail.com> writes:

> On Wed, Sep 1, 2010 at 1:56 AM, viresh kumar <viresh.kumar@st.com> wrote:
>> On 9/1/2010 1:20 PM, Stephen Boyd wrote:
>>> 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.

```
