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

[PATCH RFC 3/6] send-email: Handle "GIT:" rather than "GIT: " during --compose

From
Michael Witten <mfwitten@gmail.com>
Date
Apr 7, 2009, 21:25 UTC
Message-ID
<1239139522-24118-3-git-send-email-mfwitten@gmail.com>
In-Reply-To
<1239139522-24118-2-git-send-email-mfwitten@gmail.com>

This should make things a little more robust in terms of user input; before, even the program got it wrong by outputting a line with only "GIT:", which was left in place as a header, because there would be no following space character.

Also, I cleaned up get_patch_subject().
Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 git-send-email.perl |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 63d6063..098c620 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -505,15 +505,16 @@ if (@files) {
 }
 
 sub get_patch_subject($) {
-	my $fn = shift;
-	open (my $fh, '<', $fn);
-	while (my $line = <$fh>) {
-		next unless ($line =~ /^Subject: (.*)$/);
-		close $fh;
-		return "GIT: $1\n";
+
+	my $patch = shift;
+	open (my $fh, '<', $patch);
+
+	while (<$fh>) {
+		next unless (/^Subject: (.*)$/);
+		return $1;
 	}
-	close $fh;
-	die "No subject line in $fn ?";
+
+	die "'Subject:' line expected in '$patch'";
 }
 
 if ($compose) {
@@ -532,7 +533,7 @@ if ($compose) {
 
 	print C <<EOT;
 From $tpl_sender # This line is ignored.
-GIT: Lines beginning in "GIT: " will be removed.
+GIT: Lines beginning in "GIT:" will be removed.
 GIT: Consider including an overall diffstat or table of contents
 GIT: for the patch you are writing.
 GIT:
@@ -543,7 +544,7 @@ In-Reply-To: $tpl_reply_to
 
 EOT
 	for my $f (@files) {
-		print C get_patch_subject($f);
+		print C "GIT: ", get_patch_subject($f), "\n";
 	}
 	close(C);
 
@@ -565,7 +566,7 @@ EOT
 	my $in_body = 0;
 	my $summary_empty = 1;
 	while(<C>) {
-		next if m/^GIT: /;
+		next if m/^GIT:/;
 		if ($in_body) {
 			$summary_empty = 0 unless (/^\n$/);
 		} elsif (/^\n$/) {
-- 
1.6.2.2.448.g61445.dirty
Previous: Michael WittenNext: Michael Witten
Message 3 of 30 in “send-email: Add --delay for separating emails”
  1. 1/6 send-email: Add --delay for separating emailsMichael Witten, Apr 7, 2009
  2. 2/6 send-email: --smtp-server-port should take an integerMichael Witten, Apr 7, 2009
  3. 3/6 send-email: Handle "GIT:" rather than "GIT: " during --composeMichael Witten, Apr 7, 2009
  4. 4/6 send-email: --compose takes optional argument to existing fileMichael Witten, Apr 7, 2009
  5. 5/6 send-email: Cleanup the usage text a bitMichael Witten, Apr 7, 2009
  6. 6/6 send-email: Remove horrible mix of tabs and spacesMichael Witten, Apr 7, 2009
  7. demerphqApr 7, 2009
  8. Michael WittenApr 7, 2009
  9. demerphqApr 7, 2009
  10. demerphqApr 7, 2009
  11. Jeff KingApr 7, 2009
  12. Andreas EricssonApr 7, 2009
  13. Tomas CarneckyApr 7, 2009
  14. Jeff KingApr 8, 2009
  15. Junio C HamanoApr 11, 2009
  16. Junio C HamanoApr 11, 2009
  17. Junio C HamanoApr 11, 2009
  18. Michael WittenApr 11, 2009
  19. Junio C HamanoApr 12, 2009
  20. Michael WittenApr 12, 2009
  21. Junio C HamanoApr 7, 2009
  22. Junio C HamanoApr 11, 2009
  23. Wesley J. LandakerApr 11, 2009
  24. Michael WittenApr 11, 2009
  25. Jeff KingApr 7, 2009
  26. 1/6 Re: send-email: Add --delay for separating emailsNicolas Sebrecht, Apr 7, 2009
  27. Andreas EricssonApr 7, 2009
  28. Jeff KingApr 8, 2009
  29. Jeff KingApr 8, 2009
  30. Junio C HamanoApr 7, 2009

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.