git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-send-email w/ headers

From
Junio C Hamano <junkio@cox.net>
Date
Oct 5, 2006, 23:34 UTC
Message-ID
<7viriy9w1q.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200610041250.50272.len.brown@intel.com>
Len Brown <len.brown@intel.com> writes:
> 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.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/git-send-email.perl b/git-send-email.perl
index 4a20310..77e4557 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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
Previous: Len BrownNext: Len Brown
Message 2 of 6 in “git-send-email w/ headers”
  1. Len BrownOct 4, 2006
  2. Junio C HamanoOct 5, 2006
  3. Len BrownOct 6, 2006
  4. Junio C HamanoOct 6, 2006
  5. Len BrownOct 7, 2006
  6. David WoodhouseOct 6, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.