[PATCH RFC 05/10] send-email: Handle "GIT:" rather than "GIT: " during --compose
- From
Michael Witten <mfwitten@gmail.com>
- Date
- Apr 11, 2009, 19:08 UTC
- Message-ID
- <1239476908-25944-5-git-send-email-mfwitten@gmail.com>
- In-Reply-To
- <1239476908-25944-4-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 b689cc7..502f5af 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -507,15 +507,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) { @@ -534,7 +535,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: @@ -545,7 +546,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); @@ -567,7 +568,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.479.g2aec