{"thread":{"id":"1727","subject":"[PATCH 1/2] Make git-send-email-script ignore some unnecessary options when operating in batch mode.","startedAt":"2005-09-05T05:13:07Z","lastAt":"2005-09-05T21:10:39Z","messageCount":10,"participants":["Ryan Anderson","Martin Langhoff","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"8074","messageId":"1125897187857-git-send-email-ryan@michonline.com","threadId":"1727","inReplyTo":"11258971871874-git-send-email-ryan@michonline.com","subject":"[PATCH 1/2] Make git-send-email-script ignore some unnecessary options when operating in batch mode.","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-09-05T05:13:07Z","receivedAt":"2005-09-05T05:13:07Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"Add a \"--compose\" option that uses $EDITOR to edit an \"introductory\" email to the patch series.\n\nSigned-off-by: Ryan Anderson <ryan@michonline.com>\n\n---\n\n git-send-email-script |   86 ++++++++++++++++++++++++++++++++++++++++++++++---\n 1 files changed, 81 insertions(+), 5 deletions(-)\n\nb3c7bf0ee80c1d207c9208972f011540b4c0528f\ndiff --git a/git-send-email-script b/git-send-email-script\n--- a/git-send-email-script\n+++ b/git-send-email-script\n@@ -25,9 +25,13 @@ use Data::Dumper;\n use Email::Valid;\n \n sub unique_email_list(@);\n+sub cleanup_compose_files();\n+\n+# Constants (essentially)\n+my $compose_filename = \".msg.$$\";\n \n # Variables we fill in automatically, or via prompting:\n-my (@to,@cc,$initial_reply_to,$initial_subject,@files,$from);\n+my (@to,@cc,$initial_reply_to,$initial_subject,@files,$from,$compose);\n \n # Behavior modification variables\n my ($chain_reply_to, $smtp_server) = (1, \"localhost\");\n@@ -46,6 +50,7 @@ my $rc = GetOptions(\"from=s\" => \\$from,\n \t\t    \"to=s\" => \\@to,\n \t\t    \"chain-reply-to!\" => \\$chain_reply_to,\n \t\t    \"smtp-server=s\" => \\$smtp_server,\n+\t\t    \"compose\" => \\$compose,\n \t );\n \n # Now, let's fill any that aren't set in with defaults:\n@@ -69,7 +74,7 @@ while(<GITVAR>) {\n }\n close(GITVAR);\n \n-\n+my $prompting = 0;\n if (!defined $from) {\n \t$from = $author || $committer;\n \tdo {\n@@ -79,6 +84,7 @@ if (!defined $from) {\n \n \t$from = $_;\n \tprint \"Emails will be sent from: \", $from, \"\\n\";\n+\t$prompting++;\n }\n \n if (!@to) {\n@@ -88,19 +94,21 @@ if (!@to) {\n \t} while (!defined $_);\n \tmy $to = $_;\n \tpush @to, split /,/, $to;\n+\t$prompting++;\n }\n \n-if (!defined $initial_subject) {\n+if (!defined $initial_subject && $compose) {\n \tdo {\n \t\t$_ = $term->readline(\"What subject should the emails start with? \",\n \t\t\t$initial_subject);\n \t} while (!defined $_);\n \t$initial_subject = $_;\n+\t$prompting++;\n }\n \n-if (!defined $initial_reply_to) {\n+if (!defined $initial_reply_to && $prompting) {\n \tdo {\n-\t\t$_= $term->readline(\"Message-ID to be used as In-Reply-To? \",\n+\t\t$_= $term->readline(\"Message-ID to be used as In-Reply-To for the first email? \",\n \t\t\t$initial_reply_to);\n \t} while (!defined $_);\n \n@@ -112,6 +120,52 @@ if (!defined $smtp_server) {\n \t$smtp_server = \"localhost\";\n }\n \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+\topen(C,\">\",$compose_filename)\n+\t\tor die \"Failed to open for writing $compose_filename: $!\";\n+\tprint C \"From \\n\";\n+\tprintf C \"Subject: %s\\n\\n\", $initial_subject;\n+\tprintf C <<EOT;\n+GIT: Please enter your email below.\n+GIT: Lines beginning in \"GIT: \" will be removed.\n+GIT: Consider including an overall diffstat or table of contents\n+GIT: for the patch you are writing.\n+\n+EOT\n+\tclose(C);\n+\n+\tmy $editor = $ENV{EDITOR};\n+\t$editor = 'vi' unless defined $editor;\n+\tsystem($editor, $compose_filename);\n+\n+\topen(C2,\">\",$compose_filename . \".final\")\n+\t\tor die \"Failed to open $compose_filename.final : \" . $!;\n+\n+\topen(C,\"<\",$compose_filename)\n+\t\tor die \"Failed to open $compose_filename : \" . $!;\n+\n+\twhile(<C>) {\n+\t\tnext if m/^GIT: /;\n+\t\tprint C2 $_;\n+\t}\n+\tclose(C);\n+\tclose(C2);\n+\n+\tdo {\n+\t\t$_ = $term->readline(\"Send this email? (y|n) \");\n+\t} while (!defined $_);\n+\n+\tif (uc substr($_,0,1) ne 'Y') {\n+\t\tcleanup_compose_files();\n+\t\texit(0);\n+\t}\n+\n+\t@files = ($compose_filename . \".final\");\n+}\n+\n+\n # Now that all the defaults are set, process the rest of the command line\n # arguments and collect up the files that need to be processed.\n for my $f (@ARGV) {\n@@ -137,12 +191,24 @@ if (@files) {\n git-send-email-script [options] <file | directory> [... file | directory ]\n Options:\n    --from         Specify the \"From:\" line of the email to be sent.\n+\n    --to           Specify the primary \"To:\" line of the email.\n+\n+   --compose      Use \\$EDITOR to edit an introductory message for the\n+                  patch series.\n+\n    --subject      Specify the initial \"Subject:\" line.\n+                  Only necessary if --compose is also set.  If --compose\n+\t\t  is not set, this will be prompted for.\n+\n    --in-reply-to  Specify the first \"In-Reply-To:\" header line.\n+                  Only used if --compose is also set.  If --compose is not\n+\t\t  set, this will be prompted for.\n+\n    --chain-reply-to If set, the replies will all be to the previous\n                   email sent, rather than to the first email sent.\n                   Defaults to on.\n+\n    --smtp-server  If set, specifies the outgoing SMTP server to use.\n                   Defaults to localhost.\n \n@@ -278,6 +344,16 @@ foreach my $t (@files) {\n \tmake_message_id();\n }\n \n+if ($compose) {\n+\tcleanup_compose_files();\n+}\n+\n+sub cleanup_compose_files() {\n+\tunlink($compose_filename, $compose_filename . \".final\");\n+\n+}\n+\n+\n \n sub unique_email_list(@) {\n \tmy %seen;\n"},{"id":"8075","messageId":"11258971871874-git-send-email-ryan@michonline.com","threadId":"1727","inReplyTo":null,"subject":"[PATCH 0/2] Update git-send-email-script with --compose","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-09-05T05:13:07Z","receivedAt":"2005-09-05T05:13:07Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"\nAs I promised Junio a few weeks ago (via private email), here's an update to git-send-email-script\nthat fixes a few annoying things it does.\n\n1. No longer require --subject for most uses.\n2. No longer require --in-reply-to for most uses.\n3. If not given as command line parameters, don't prompt for either 1 or 2.\n4. Add --compose that lets the user compose an email using $EDITOR, and make\nuse of --subject and --in-reply-to\n\nThe first patch is the update to the code, the second patch updates the\ndocumentation to match.  And the fact that this is on the list at all is proof\nthat it works (for me, at least.)\n\n-- \nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"8076","messageId":"11258971872608-git-send-email-ryan@michonline.com","threadId":"1727","inReplyTo":"1125897187857-git-send-email-ryan@michonline.com","subject":"[PATCH 2/2] Update documentation of --compose to git-send-email-script.txt","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-09-05T05:13:07Z","receivedAt":"2005-09-05T05:13:07Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"Signed-off-by: Ryan Anderson <ryan@michonline.com>\n\n---\n\n Documentation/git-send-email-script.txt |   13 +++++++++----\n 1 files changed, 9 insertions(+), 4 deletions(-)\n\n60765e20aa12da748f43204e25cb582f88fb16c8\ndiff --git a/Documentation/git-send-email-script.txt b/Documentation/git-send-email-script.txt\n--- a/Documentation/git-send-email-script.txt\n+++ b/Documentation/git-send-email-script.txt\n@@ -33,16 +33,21 @@ The options available are:\n \tthe value GIT_COMMITTER_IDENT, as returned by \"git-var -l\".\n \tThe user will still be prompted to confirm this entry.\n \n+   --compose\n+\tUse \\$EDITOR to edit an introductory message for the\n+\tpatch series.\n+\n    --subject\n    \tSpecify the initial subject of the email thread.\n+\tOnly necessary if --compose is also set.  If --compose\n+\tis not set, this will be prompted for.\n \n    --in-reply-to\n \tSpecify the contents of the first In-Reply-To header.\n \tSubsequent emails will refer to the previous email \n-\tinstead of this.\n-\tWhen overriding on the command line, it may be necessary\n-\tto set this to a space.  For example\n-\t\t--in-reply-to=\" \"\n+\tinstead of this if --chain-reply-to is set (the default)\n+\tOnly necessary if --compose is also set.  If --compose\n+\tis not set, this will be prompted for.\n \n    --chain-reply-to, --no-chain-reply-to\n \tIf this is set, each email will be sent as a reply to the previous\n"},{"id":"8085","messageId":"46a038f905090504166246dc0a@mail.gmail.com","threadId":"1727","inReplyTo":"11258971871874-git-send-email-ryan@michonline.com","subject":"Re: [PATCH 0/2] Update git-send-email-script with --compose","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-09-05T11:16:57Z","receivedAt":"2005-09-05T11:16:57Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"Ryan,\n\nis it possible to fix the git-send-email script to \"just work\" reading\nin the emails that `git-format-patch-script -o patchdir origin`\ngenerates? I have a very ugly local patch to git-send-email-script\nthat\n\n - reads \"from\" from git-var, can be overridden by passing an explicit --from\n - reads \"subject\" from the first line of STDIN or file. If the line\ndoesn't start with [PATCH it provides the [PATCH] prefix. I found it\nreally confusing that it wants to get 'from' in the first line...\nthat's not what git-format-patch produces!\n - it never prompts for anything\n\nI then invoke it with \n\n  git-send-email-script --to git@vger.kernel.org patches/0001-bad-uglypatch\n\nand it \"just works\". I haven't sent them anywhere because I just\nwanted it to work locally for me, and it's just a bunch of hacks. And\nyou are clearly using something other than git-format-patch to\ngenerate those patchfiles -- and my patches would break that.\n\nOTOH, it'd be great if it did support the git-format-patch output. Let\nme know if you want bits and pieces of my hack - though it's trivial.\n\ncheers,\n\n\nmartin\n"},{"id":"8091","messageId":"20050905153705.GD5335@mythryan2.michonline.com","threadId":"1727","inReplyTo":"46a038f905090504166246dc0a@mail.gmail.com","subject":"Re: [PATCH 0/2] Update git-send-email-script with --compose","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-09-05T15:37:05Z","receivedAt":"2005-09-05T15:37:05Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"On Mon, Sep 05, 2005 at 11:16:57PM +1200, Martin Langhoff wrote:\n> Ryan,\n> \n> is it possible to fix the git-send-email script to \"just work\" reading\n> in the emails that `git-format-patch-script -o patchdir origin`\n> generates? I have a very ugly local patch to git-send-email-script\n> that\n> \n>  - reads \"from\" from git-var, can be overridden by passing an explicit --from\n\ngit-send-email-script already reads the \"From:\" from git-var - but I\nsuppose I should only *prompt* for the from if something isn't\nsatisfactory with the output of git-var.  TODO #1\n\n>  - reads \"subject\" from the first line of STDIN or file. If the line\n> doesn't start with [PATCH it provides the [PATCH] prefix. I found it\n> really confusing that it wants to get 'from' in the first line...\n> that's not what git-format-patch produces!\n\nSorry about that - I always export using git-format-patch using --mbox,\nand those work nicely.  I'm a bit reluctant to do the [PATCH] fixup, but\nI think I will:\n\n\t1. Detect [PATCH] or [PATCH [0-9]+/[0-9]+] (Sorry for the horrid\n\tfake-regexp)\n\t2. Provide a --no-fixup-subject to turn that off.\n\n(TODO #2)\n\n>  - it never prompts for anything\n\nI think I'm tending in that direction - I'll keep making the prompting a\nfall-back by adding better default detection.\n\nIn this case, remember that this was an attempt to help users patch bomb\nlists, getting all the subtle details correct.  The prompting is there\nto help get the subtle details correct!\n\n> I then invoke it with \n> \n>   git-send-email-script --to git@vger.kernel.org patches/0001-bad-uglypatch\n> \n> and it \"just works\". I haven't sent them anywhere because I just\n> wanted it to work locally for me, and it's just a bunch of hacks. And\n> you are clearly using something other than git-format-patch to\n> generate those patchfiles -- and my patches would break that.\n\nWell, I'm not.  Try \"git format-patch --mbox -o patchdir origin\" and see\nif that works better for you.\n\n> OTOH, it'd be great if it did support the git-format-patch output. Let\n> me know if you want bits and pieces of my hack - though it's trivial.\n\nSure, send it at me, and I'll see what I can incorporate.\n\nI do apologize for not realizing that the default git format-patch\noutput doesn't match what git send-email script expects the \"legacy\"\nmode - I'll sort that out one way or another as well. (TODO #3)\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"8106","messageId":"7vll2b4ake.fsf@assigned-by-dhcp.cox.net","threadId":"1727","inReplyTo":"20050905153705.GD5335@mythryan2.michonline.com","subject":"Re: [PATCH 0/2] Update git-send-email-script with --compose","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-05T18:46:25Z","receivedAt":"2005-09-05T18:46:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ryan Anderson <ryan@michonline.com> writes:\n\n> On Mon, Sep 05, 2005 at 11:16:57PM +1200, Martin Langhoff wrote:\n>> \n>>  - reads \"subject\" from the first line of STDIN or file. If the line\n>> doesn't start with [PATCH it provides the [PATCH] prefix. I found it\n>> really confusing that it wants to get 'from' in the first line...\n>> that's not what git-format-patch produces!\n>\n> Sorry about that - I always export using git-format-patch using --mbox,\n> and those work nicely.  I'm a bit reluctant to do the [PATCH] fixup, but\n> I think I will:\n>\n> \t1. Detect [PATCH] or [PATCH [0-9]+/[0-9]+] (Sorry for the horrid\n> \tfake-regexp)\n> \t2. Provide a --no-fixup-subject to turn that off.\n>\n> (TODO #2)\n\nTo be consistent with the other tools in tools/ directory, the\nabove is probably 's/^/[PATCH] / unless (/^\\[PATCH/])'\n\n> In this case, remember that this was an attempt to help users patch bomb\n> lists, getting all the subtle details correct.  The prompting is there\n> to help get the subtle details correct!\n\nYou could error out without asking if that is what is happening.\n\n> Well, I'm not.  Try \"git format-patch --mbox -o patchdir origin\" and see\n> if that works better for you.\n\nMartin, --mbox has the added benefit that it consistently\npreserves the From: and Date: information even for your own\npatches, because it implies --date and --author.  By default\nwithout --author and --date these are not preserved from the\noriginal commits for your own patches, primarily because\nformat-patch without --mbox was written for reorganizing and\nreordering existing patches (i.e. export, concatenate some, edit\nsome hunks, and eventually feed it to applymbox to make commits;\nyou do not typically want to keep the original author date for\nthis kind of use).\n\n> I do apologize for not realizing that the default git format-patch\n> output doesn't match what git send-email script expects the \"legacy\"\n> mode - I'll sort that out one way or another as well. (TODO #3)\n\nI do apologize for not really saying what --mbox does and what\nthe format-patch output without --mbox is meant for.\n\nMartin, is there a reason you do not want --mbox format\n(e.g. format-patch --mbox spits out Subject: line undesirably\nformatted while it does what you want without --mbox)?\n"},{"id":"8109","messageId":"46a038f90509051306212d4e93@mail.gmail.com","threadId":"1727","inReplyTo":"7vll2b4ake.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 0/2] Update git-send-email-script with --compose","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-09-05T20:06:50Z","receivedAt":"2005-09-05T20:06:50Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 9/6/05, Junio C Hamano <junkio@cox.net> wrote:\n> Ryan Anderson <ryan@michonline.com> writes:\n> > Sorry about that - I always export using git-format-patch using --mbox,\n> > and those work nicely.  I'm a bit reluctant to do the [PATCH] fixup, but\n> > I think I will:\n\nThanks Ryan for the clarification! I hadn't realized it would work\ncorrectly with --mbox -- unfortunately it doesn't work very well in\nthe one-file-per-patch (legacy?) mode. Also, telling it _not_ to\nprompt when it can guess it, is far better (a confirm y/n can still be\na good thing if you want to ensure the user gets a chance to review\nthe values guessed).\n\n> Martin, --mbox has the added benefit that it consistently\n> preserves the From: and Date: information even for your own\n> patches, because it implies --date and --author.  By default\n> without --author and --date these are not preserved from the\n> original commits for your own patches, primarily because\n> format-patch without --mbox was written for reorganizing and\n> reordering existing patches (i.e. export, concatenate some, edit\n> some hunks, and eventually feed it to applymbox to make commits;\n> you do not typically want to keep the original author date for\n> this kind of use).\n\nFair enough -- blame it on my primitive approach of only having 2\nworking repositories, and having some patches in them that I'm not\npushing upstream. Exporting to mbox would mean that I have to edit the\nmbox file to remove the patches I don't intend to publish.\n\n... and on my naive reading of git-send-email documentation -- it\ndoesn't mention mbox format at all, so I assumed it would expect one\npatch per file.\n\n> Martin, is there a reason you do not want --mbox format\n> (e.g. format-patch --mbox spits out Subject: line undesirably\n> formatted while it does what you want without --mbox)?\n\nHmmm -- that I am too lazy to keep several heads or several repos, and\norganize them to have a \"tojunio\" branch? So far I've been working on\none or two files (archimport) and customizing a couple of others with\nstrictly local changes (git-send-email for instance), so it didn't\nmake sense to formally segregate the heads. A simple review and manual\n\"cherrypicking\" of the patches I wanted to send was enough.\n\ncheers,\n\n\nmartin\n"},{"id":"8110","messageId":"7vslwj2qty.fsf@assigned-by-dhcp.cox.net","threadId":"1727","inReplyTo":"46a038f90509051306212d4e93@mail.gmail.com","subject":"Re: [PATCH 0/2] Update git-send-email-script with --compose","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-05T20:38:01Z","receivedAt":"2005-09-05T20:38:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n> Fair enough -- blame it on my primitive approach of only having 2\n> working repositories, and having some patches in them that I'm not\n> pushing upstream. Exporting to mbox would mean that I have to edit the\n> mbox file to remove the patches I don't intend to publish.\n>\n> ... and on my naive reading of git-send-email documentation -- it\n> doesn't mention mbox format at all, so I assumed it would expect one\n> patch per file.\n\nNot really; --mbox output is one-file-per-patch and it is up to\nyou which ones to pick and concatenate them in what order, if you\nwant them in a single file.\n"},{"id":"8111","messageId":"46a038f905090513456d67842b@mail.gmail.com","threadId":"1727","inReplyTo":"7vslwj2qty.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 0/2] Update git-send-email-script with --compose","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-09-05T20:45:54Z","receivedAt":"2005-09-05T20:45:54Z","isPatch":true,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 9/6/05, Junio C Hamano <junkio@cox.net> wrote:\n> Not really; --mbox output is one-file-per-patch and it is up to\n> you which ones to pick and concatenate them in what order, if you\n> want them in a single file.\n\nHrmmmm. Then I better hide away in a little cave, and shut my big mouth up. ;-)\n\nIt shows that I was never familiar with the practices of linux\nhackers. I've always read the references to mboxes holding patchbombs\nmeaning literally one mbox file with a zillion contatenated patches\nreceived via email.\n\napologies,\n\n\nmartin\n"},{"id":"8112","messageId":"7vek832pbk.fsf@assigned-by-dhcp.cox.net","threadId":"1727","inReplyTo":"46a038f905090513456d67842b@mail.gmail.com","subject":"Re: [PATCH 0/2] Update git-send-email-script with --compose","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-05T21:10:39Z","receivedAt":"2005-09-05T21:10:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin.langhoff@gmail.com> writes:\n\n> It shows that I was never familiar with the practices of linux\n> hackers. I've always read the references to mboxes holding patchbombs\n> meaning literally one mbox file with a zillion contatenated patches\n> received via email.\n\nTo be fair to you, it is _not_ the practices of Linux hackers.\nFor one thing, I am not among them.  I think it is perfectly\nreasonable to expect it to produce a single mailbox, like you\nexpected.\n\nThe primary reason why \"format-patch --mbox\" only does one file\nper patch is because I am too lazy to add a --single-mbox option\nwhich does the \"right thing\".  This _could_ be \"fixed\", but on\nthe other hand the current one file per patch behaviour is\narguably more flexible than always creating a single mbox, and\nthat is what I use as an excuse to justify my laziness ;-).\n"}]}