send-email: use lexical filehandles for $compose
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.comReviewed-by: Avery Pennarun <apenwarr@gmail.com> Reviewed-by: Jeff King <peff@peff.net> > Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Sep 30, 2010 at 13:42 UTC
fe0f944f3bbe4adac815808654b16837a05905fc
1 file changed
+11
-11
git-send-email.perl
+11
-11
@@ -567,7 +567,7 @@ if ($compose) {
567
$compose_filename = ($repo ?
568
tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) :
569
tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1];
570
- open(C,">",$compose_filename)
570
+ open my $c, ">", $compose_filename
571
or die "Failed to open for writing $compose_filename: $!";
572
573
@@ -575,7 +575,7 @@ if ($compose) {
575
my $tpl_subject = $initial_subject || '';
576
my $tpl_reply_to = $initial_reply_to || '';
577
578
- print C <<EOT;
578
+ print $c <<EOT;
579
From $tpl_sender # This line is ignored.
580
GIT: Lines beginning in "GIT:" will be removed.
581
GIT: Consider including an overall diffstat or table of contents
@@ -588,9 +588,9 @@ In-Reply-To: $tpl_reply_to
588
589
EOT
590
for my $f (@files) {
591
- print C get_patch_subject($f);
591
+ print $c get_patch_subject($f);
592
}
593
- close(C);
593
+ close $c;
594
595
if ($annotate) {
596
do_edit($compose_filename, @files);
@@ -598,23 +598,23 @@ EOT
598
do_edit($compose_filename);
599
}
600
601
- open(C2,">",$compose_filename . ".final")
601
+ open my $c2, ">", $compose_filename . ".final"
602
or die "Failed to open $compose_filename.final : " . $!;
603
604
- open(C,"<",$compose_filename)
604
+ open $c, "<", $compose_filename
605
or die "Failed to open $compose_filename : " . $!;
606
607
my $need_8bit_cte = file_has_nonascii($compose_filename);
608
my $in_body = 0;
609
my $summary_empty = 1;
610
- while(<C>) {
610
+ while(<$c>) {
611
next if m/^GIT:/;
612
if ($in_body) {
613
$summary_empty = 0 unless (/^\n$/);
614
} elsif (/^\n$/) {
615
$in_body = 1;
616
if ($need_8bit_cte) {
617
- print C2 "MIME-Version: 1.0\n",
617
+ print $c2 "MIME-Version: 1.0\n",
618
"Content-Type: text/plain; ",
619
"charset=UTF-8\n",
620
"Content-Transfer-Encoding: 8bit\n";
@@ -639,10 +639,10 @@ EOT
639
print "To/Cc/Bcc fields are not interpreted yet, they have been ignored\n";
640
next;
641
}
642
- print C2 $_;
642
+ print $c2 $_;
643
}
644
- close(C);
645
- close(C2);
644
+ close $c;
645
+ close $c2;
646
647
if ($summary_empty) {
648
print "Summary email is empty, skipping it\n";