git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] send-email: don't create temporary compose file until it is needed
@ 2009-02-23 18:51 Jay Soffian
  0 siblings, 0 replies; only message in thread
From: Jay Soffian @ 2009-02-23 18:51 UTC (permalink / raw)
  To: git; +Cc: Jay Soffian, gitster

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>
---
 git-send-email.perl |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 54e7617..adf7ecb 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -156,10 +156,7 @@ if ($@) {
 # 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;
@@ -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;
@@ -505,6 +504,9 @@ sub get_patch_subject($) {
 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: $!";
 
-- 
1.6.2.rc1.268.g83c06

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-23 18:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-23 18:51 [PATCH] send-email: don't create temporary compose file until it is needed Jay Soffian

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 NNTP newsgroup(s).