Skip to contentSkip to conversation

git-send-email w/ headers

PATCH Len Brown 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore

Len Brown

author
#0 lore raw

git-send-email seems to strip out my custom headers.

git-format-patch says it can do this:

CONFIGURATION
You can specify extra mail header lines to be added to each message in the repository configuration as follows:
headers = "Organization: git-foo\n"

So I have this:

$ cat .git/config
[format]
        headers = Reply-To: Len Brown <[email protected]>\nOrganization: Intel Open Source Technology Center\n
$ git-format-patch -o foo -n --thread master..lenb
seems to correctly pick up the headers:
$ cat foo/0001-test-create-junk.txt
From 6706b39a213064d00af0ec58a159b71b0719a3b4 Mon Sep 17 00:00:00 2001
Message-Id: <6706b39a213064d00af0ec58a159b71b0719a3b4.1159941986.git.len.brown@intel.com>
From: Len Brown <[email protected]>
Reply-To: Len Brown <[email protected]>
Organization: Intel Open Source Technology Center
Date: Wed, 4 Oct 2006 01:11:12 -0400
Subject: [PATCH 1/14] test: create junk
---
 junk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
junk new file +1 -0
new file mode 100644
index 0000000..9ecf3cf
@@ -0,0 +1 @@
+this

--
1.4.2.3.g128e

$ git-send-email  --no-chain-reply-to --compose --to [email protected] --smtp-server smpt.comcast.net --suppress-from foo

and i receive a message w/o the Organization and Reply-to headers:

$ cat ~/Documents/test.e-mail-received
From [email protected] Wed Oct  4 12:34:51 2006
Return-Path: <[email protected]>
Received: from alnrmhc12.comcast.net (alnrmhc12.comcast.net [206.18.177.52])
        by hera.kernel.org (8.13.7/8.13.7) with ESMTP id k94GVifO030722
        for <[email protected]>; Wed, 4 Oct 2006 16:32:17 GMT
Received: from localhost.localdomain (c-65-96-213-102.hsd1.ma.comcast.net[65.96.213.102])
          by comcast.net (alnrmhc12) with SMTP
          id <20061004163139b1200eq2t6e>; Wed, 4 Oct 2006 16:31:39 +0000
From: Len Brown <[email protected]>
To: [email protected]
Cc: Len Brown <[email protected]>
Subject: [PATCH 1/14] test: create junk
Date: Wed,  4 Oct 2006 12:34:51 -0400
Message-Id: <[email protected]>
X-Mailer: git-send-email 1.4.2.3.g128e
In-Reply-To: <[email protected]>
References: <[email protected]>
X-Virus-Scanned: ClamAV 0.88.4/1997/Wed Oct  4 15:20:43 2006 on hera.kernel.org
X-Virus-Status: Clean
X-Spam-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,
        FORGED_RCVD_HELO autolearn=ham version=3.1.3
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on hera.kernel.org
Status: R
X-Status: NGC
X-KMail-EncryptionState:
X-KMail-SignatureState:
X-KMail-MDN-Sent:
---
 junk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
junk new file +1 -0
new file mode 100644
index 0000000..9ecf3cf
@@ -0,0 +1 @@
+this

--
1.4.2.3.g128e

Same thing happens if I use the SMTP server inside Intel.
I haven't figured out how to send directly via kernel.org using this command kmail uses a password and ssh to talk to kernel.org.
This is actually sort of an issue too, because smtp.comcast.net limits the number of messages sent per connection and
will drop after 10 messages with this:
requested action aborted: too many messages on a single connection

thanks,
-Len

#1 lore raw
Quoted 1 line · Len Brown

git-send-email seems to strip out my custom headers.

It seems to not care about anything but a selected few.

Could you give this a try, please?

-- >8 --
git-send-email: do not drop custom headers the user prepared

The command picked up only Subject, CC, and From headers in the incoming mbox text. Sending out patches prepared by git-format-patch with user's custom headers was impossible with that.

Just keep the ones it does not need to look at and add them to the header of the message when sending it out.

---

git-send-email.perl +8 -1
index 4a20310..77e4557 100755
@@ -83,7 +83,7 @@ # Constants (essentially)
 my $compose_filename = ".msg.$$";
 
 # Variables we fill in automatically, or via prompting:
-my (@to,@cc,@initial_cc,@bcclist,
+my (@to,@cc,@initial_cc,@bcclist,@xh,
 	$initial_reply_to,$initial_subject,@files,$from,$compose,$time);
 
 # Behavior modification variables
@@ -422,6 +422,9 @@ X-Mailer: git-send-email $gitversion
 		$header .= "In-Reply-To: $reply_to\n";
 		$header .= "References: $references\n";
 	}
+	if (@xh) {
+		$header .= join("\n", @xh);
+	}
 
 	if ($smtp_server =~ m#^/#) {
 		my $pid = open my $sm, '|-';
@@ -472,6 +475,7 @@ foreach my $t (@files) {
 
 	my $author_not_sender = undef;
 	@cc = @initial_cc;
+	@xh = ();
 	my $found_mbox = 0;
 	my $header_done = 0;
 	$message = "";
@@ -495,6 +499,9 @@ foreach my $t (@files) {
 						$2, $_) unless $quiet;
 					push @cc, $2;
 				}
+				elsif (/^[-A-Za-z]+:\s+\S/) {
+					push @xh, $_;
+				}
 
 			} else {
 				# In the traditional
#2 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 1 line · Len Brown

git-send-email seems to strip out my custom headers.

It seems to not care about anything but a selected few.

Could you give this a try, please?

It also needs to preserve (and indeed to provide by default) Content-Type headers to specify the character set.

Signature · 1 line
dwmw2
author
#3 lore raw
In reply to Junio C Hamano
Quoted 7 lines · Junio C Hamano
Quoted 1 line · Len Brown

git-send-email seems to strip out my custom headers.

It seems to not care about anything but a selected few.

Could you give this a try, please?

The good news is that the message received now includes the custom headers from the original message.

But the Signed-off-by: line from the original message body
has now been swallowed up into the message header -- so my mailer doesn't display it.

thanks,
-Len

Original Message:
From 42f19e47f7e720cce936e4fdbaa979b6d4cf2f13 Mon Sep 17 00:00:00 2001
Message-Id: <42f19e47f7e720cce936e4fdbaa979b6d4cf2f13.1160108957.git.len.brown@intel.com>
From: Len Brown <[email protected]>
Date: Wed, 4 Oct 2006 01:11:12 -0400
Subject: [PATCH 1/14] test: create junk
Reply-To: Len Brown <[email protected]>
Organization: Intel Open Source Technology Center

---
 junk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
junk new file +1 -0
new file mode 100644
index 0000000..9ecf3cf
@@ -0,0 +1 @@
+this

--
1.4.2.3.gabd6-dirty

Received Message:

Return-Path: <[email protected]>
Received: from alnrmhc13.comcast.net (alnrmhc13.comcast.net [206.18.177.53])

        by hera.kernel.org (8.13.7/8.13.7) with ESMTP id k964RZPa026442
        for <[email protected]>; Fri, 6 Oct 2006 04:28:01 GMT

Received: from localhost.localdomain (c-65-96-213-102.hsd1.ma.comcast.net[65.96.213.102])
by comcast.net (alnrmhc13) with SMTP
id <20061006042729b1300l5679e>; Fri, 6 Oct 2006 04:27:30 +0000
From: Len Brown <[email protected]>
To: [email protected]
Cc: Len Brown <[email protected]>
Subject: [PATCH 1/14] test: create junk
Date: Fri, 6 Oct 2006 00:30:29 -0400
Message-Id: <[email protected]>
X-Mailer: git-send-email 1.4.2.3.gabd6-dirty
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-Id: <42f19e47f7e720cce936e4fdbaa979b6d4cf2f13.1160108957.git.len.brown@intel.com>
Date: Wed, 4 Oct 2006 01:11:12 -0400
Reply-To: Len Brown <[email protected]>
Organization: Intel Open Source Technology Center

X-Virus-Scanned: ClamAV 0.88.4/1999/Thu Oct 5 17:35:38 2006 on hera.kernel.org
X-Virus-Status: Clean
X-Spam-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,
FORGED_RCVD_HELO,INVALID_DATE autolearn=no version=3.1.3
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on hera.kernel.org
Status: R
X-Status: NGC
X-KMail-EncryptionState:
X-KMail-SignatureState:
X-KMail-MDN-Sent:
Content-Type:

---
 junk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
junk new file +1 -0
new file mode 100644
index 0000000..9ecf3cf
@@ -0,0 +1 @@
+this
Signature · 1 line
1.4.2.3.gabd6-dirty
#4 lore raw
Quoted 3 lines · Len Brown

But the Signed-off-by: line from the original message body has now been swallowed up into the message header -- so my mailer doesn't display it.

Sorry, what I sent out has worse breakage than not having your custom header. It would eat the first paragraph of your message X-<.

A replacement patch is attached. If you have already applied the previous patch, you can hand edit the line that says:

	$header .= join("\n", @xh);

to

	$header .= join("\n", @xh) . "\n";

It forgets to end the last line of the headers with LF.

---

git-send-email.perl +8 -1
index 3f50aba..2fd5e87 100755
@@ -83,7 +83,7 @@ # Constants (essentially)
 my $compose_filename = ".msg.$$";
 
 # Variables we fill in automatically, or via prompting:
-my (@to,@cc,@initial_cc,@bcclist,
+my (@to,@cc,@initial_cc,@bcclist,@xh,
 	$initial_reply_to,$initial_subject,@files,$from,$compose,$time);
 
 # Behavior modification variables
@@ -422,6 +422,9 @@ X-Mailer: git-send-email $gitversion
 		$header .= "In-Reply-To: $reply_to\n";
 		$header .= "References: $references\n";
 	}
+	if (@xh) {
+		$header .= join("\n", @xh) . "\n";
+	}
 
 	if ($smtp_server =~ m#^/#) {
 		my $pid = open my $sm, '|-';
@@ -472,6 +475,7 @@ foreach my $t (@files) {
 
 	my $author_not_sender = undef;
 	@cc = @initial_cc;
+	@xh = ();
 	my $found_mbox = 0;
 	my $header_done = 0;
 	$message = "";
@@ -495,6 +499,9 @@ foreach my $t (@files) {
 						$2, $_) unless $quiet;
 					push @cc, $2;
 				}
+				elsif (/^[-A-Za-z]+:\s+\S/) {
+					push @xh, $_;
+				}
 
 			} else {
 				# In the traditional
author
#5 lore raw
Quoted 11 lines · Junio C Hamano
Quoted 3 lines · Len Brown

But the Signed-off-by: line from the original message body has now been swallowed up into the message header -- so my mailer doesn't display it.

Sorry, what I sent out has worse breakage than not having your custom header. It would eat the first paragraph of your message X-<.

A replacement patch is attached.

Latest patch seems to be doing the right thing (included below).

However, I've discovered another rough edge. git-send-email offers to --compose an initial message, but it doesn't pick up the .git/config header like git-format-patch does:

$ cat .git/config
[format]
        headers = Reply-To: Len Brown <[email protected]>\nOrganization: Intel Open Source Technology Center\n

thanks,
-Len

Return-Path: <[email protected]>
Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [63.240.77.83])

        by hera.kernel.org (8.13.7/8.13.7) with ESMTP id k974Of6m010205
        for <[email protected]>; Sat, 7 Oct 2006 04:25:09 GMT

Received: from localhost.localdomain (c-65-96-213-102.hsd1.ma.comcast.net[65.96.213.102])
by comcast.net (sccrmhc13) with SMTP
id <2006100704243601300452mke>; Sat, 7 Oct 2006 04:24:36 +0000
From: Len Brown <[email protected]>
To: [email protected]
Cc: Len Brown <[email protected]>
Subject: [PATCH 1/14] test: create junk
Date: Sat, 7 Oct 2006 00:27:35 -0400
Message-Id: <[email protected]>
X-Mailer: git-send-email 1.4.2.3.gabd6-dirty
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-Id: <7488d8f01c21a6411ad99c1d16e95ecd6e1542a6.1160195250.git.len.brown@intel.com>
Date: Wed, 4 Oct 2006 01:11:12 -0400
Reply-To: Len Brown <[email protected]>
Organization: Intel Open Source Technology Center
X-Virus-Scanned: ClamAV 0.88.4/2002/Fri Oct 6 22:58:03 2006 on hera.kernel.org
X-Virus-Status: Clean
X-Spam-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,
FORGED_RCVD_HELO,INVALID_DATE autolearn=no version=3.1.3
X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on hera.kernel.org
Status: R
X-Status: NGC
X-KMail-EncryptionState:
X-KMail-SignatureState:
X-KMail-MDN-Sent:

---
 junk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
junk new file +1 -0
new file mode 100644
index 0000000..9ecf3cf
@@ -0,0 +1 @@
+this
Signature · 1 line
1.4.2.3.gabd6-dirty