Skip to content

Commit

Permalink
send-email: don't create temporary compose file until it is needed
Browse files Browse the repository at this point in the history
Commit eed6ca7 caused a minor regression when it switched to using
tempfile() to generate the temporary compose file. Since tempfile()
creates the file at the time it generates the filename, zero-length
temporary files are being left behind unless --compose is used (in which
case the file is cleaned up).

This patch fixes the regression by not calling tempfile() to generate
the compose filename unless --compose is in use.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jay Soffian authored and Junio C Hamano committed Feb 24, 2009
1 parent 3531e27 commit afe756c
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ sub format_2822_time {
# Behavior modification variables
my ($quiet, $dry_run) = (0, 0);
my $format_patch;
my $compose_filename = ($repo ?
tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) :
tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1];

my $compose_filename;

# Handle interactive edition of files.
my $multiedit;
Expand Down Expand Up @@ -222,11 +219,13 @@ sub signal_handler {
system "stty echo";

# tmp files from --compose
if (-e $compose_filename) {
print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
}
if (-e ($compose_filename . ".final")) {
print "'$compose_filename.final' contains the composed email.\n"
if (defined $compose_filename) {
if (-e $compose_filename) {
print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
}
if (-e ($compose_filename . ".final")) {
print "'$compose_filename.final' contains the composed email.\n"
}
}

exit;
Expand Down Expand Up @@ -505,6 +504,9 @@ ($)
if ($compose) {
# Note that this does not need to be secure, but we will make a small
# effort to have it be unique
$compose_filename = ($repo ?
tempfile(".gitsendemail.msg.XXXXXX", DIR => $repo->repo_path()) :
tempfile(".gitsendemail.msg.XXXXXX", DIR => "."))[1];
open(C,">",$compose_filename)
or die "Failed to open for writing $compose_filename: $!";

Expand Down

0 comments on commit afe756c

Please sign in to comment.