git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Michael Witten <mfwitten@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH RFC 3/6] send-email: Handle "GIT:" rather than "GIT: " during --compose
Date: Tue,  7 Apr 2009 16:25:19 -0500	[thread overview]
Message-ID: <1239139522-24118-3-git-send-email-mfwitten@gmail.com> (raw)
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

  reply	other threads:[~2009-04-07 21:28 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-07 21:25 [PATCH RFC 1/6] send-email: Add --delay for separating emails Michael Witten
2009-04-07 21:25 ` [PATCH RFC 2/6] send-email: --smtp-server-port should take an integer Michael Witten
2009-04-07 21:25   ` Michael Witten [this message]
2009-04-07 21:25     ` [PATCH RFC 4/6] send-email: --compose takes optional argument to existing file Michael Witten
2009-04-07 21:25       ` [PATCH RFC 5/6] send-email: Cleanup the usage text a bit Michael Witten
2009-04-07 21:25         ` [PATCH RFC 6/6] send-email: Remove horrible mix of tabs and spaces Michael Witten
2009-04-07 21:35           ` demerphq
2009-04-07 21:42             ` Michael Witten
2009-04-07 21:44               ` demerphq
2009-04-07 21:57                 ` demerphq
2009-04-07 22:00               ` Jeff King
2009-04-07 22:10                 ` Andreas Ericsson
2009-04-07 23:33                   ` Tomas Carnecky
2009-04-08  2:02                   ` Jeff King
2009-04-11 19:22         ` [PATCH RFC 5/6] send-email: Cleanup the usage text a bit Junio C Hamano
2009-04-11 19:22       ` [PATCH RFC 4/6] send-email: --compose takes optional argument to existing file Junio C Hamano
2009-04-11 19:22     ` [PATCH RFC 3/6] send-email: Handle "GIT:" rather than "GIT: " during --compose Junio C Hamano
2009-04-11 20:45       ` Michael Witten
2009-04-12  0:59         ` Junio C Hamano
2009-04-12  2:36           ` Michael Witten
2009-04-07 23:20   ` [PATCH RFC 2/6] send-email: --smtp-server-port should take an integer Junio C Hamano
2009-04-11 19:22   ` Junio C Hamano
2009-04-11 21:01     ` Wesley J. Landaker
2009-04-11 21:07       ` Michael Witten
2009-04-07 21:51 ` [PATCH RFC 1/6] send-email: Add --delay for separating emails Jeff King
2009-04-07 22:08   ` [PATCH RFC 1/6] " Nicolas Sebrecht
2009-04-07 22:17     ` Andreas Ericsson
2009-04-08  6:05       ` Jeff King
2009-04-08  6:03     ` Jeff King
2009-04-07 23:17 ` [PATCH RFC 1/6] " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1239139522-24118-3-git-send-email-mfwitten@gmail.com \
    --to=mfwitten@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).