{"thread":{"id":"17975","subject":"[PATCH] send-email: don't create temporary compose file until it is needed","startedAt":"2009-02-23T18:51:37Z","lastAt":"2009-02-23T18:51:37Z","messageCount":1,"participants":["Jay Soffian"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"105928","messageId":"1235415097-16403-1-git-send-email-jaysoffian@gmail.com","threadId":"17975","inReplyTo":null,"subject":"[PATCH] send-email: don't create temporary compose file until it is needed","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-23T18:51:37Z","receivedAt":"2009-02-23T18:51:37Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Commit eed6ca7 caused a minor regression when it switched to using\ntempfile() to generate the temporary compose file. Since tempfile()\ncreates the file at the time it generates the filename, zero-length\ntemporary files are being left behind unless --compose is used (in which\ncase the file is cleaned up).\n\nThis patch fixes the regression by not calling tempfile() to generate\nthe compose filename unless --compose is in use.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n git-send-email.perl |   20 +++++++++++---------\n 1 files changed, 11 insertions(+), 9 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 54e7617..adf7ecb 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -156,10 +156,7 @@ if ($@) {\n # Behavior modification variables\n my ($quiet, $dry_run) = (0, 0);\n my $format_patch;\n-my $compose_filename = ($repo ?\n-\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => $repo->repo_path()) :\n-\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => \".\"))[1];\n-\n+my $compose_filename;\n \n # Handle interactive edition of files.\n my $multiedit;\n@@ -222,11 +219,13 @@ sub signal_handler {\n \tsystem \"stty echo\";\n \n \t# tmp files from --compose\n-\tif (-e $compose_filename) {\n-\t\tprint \"'$compose_filename' contains an intermediate version of the email you were composing.\\n\";\n-\t}\n-\tif (-e ($compose_filename . \".final\")) {\n-\t\tprint \"'$compose_filename.final' contains the composed email.\\n\"\n+\tif (defined $compose_filename) {\n+\t\tif (-e $compose_filename) {\n+\t\t\tprint \"'$compose_filename' contains an intermediate version of the email you were composing.\\n\";\n+\t\t}\n+\t\tif (-e ($compose_filename . \".final\")) {\n+\t\t\tprint \"'$compose_filename.final' contains the composed email.\\n\"\n+\t\t}\n \t}\n \n \texit;\n@@ -505,6 +504,9 @@ sub get_patch_subject($) {\n if ($compose) {\n \t# Note that this does not need to be secure, but we will make a small\n \t# effort to have it be unique\n+\t$compose_filename = ($repo ?\n+\t\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => $repo->repo_path()) :\n+\t\ttempfile(\".gitsendemail.msg.XXXXXX\", DIR => \".\"))[1];\n \topen(C,\">\",$compose_filename)\n \t\tor die \"Failed to open for writing $compose_filename: $!\";\n \n-- \n1.6.2.rc1.268.g83c06\n"}]}