{"thread":{"id":"16108","subject":"[PATCH 2/3] git send-email: interpret unknown files as revision lists","startedAt":"2008-10-31T10:57:09Z","lastAt":"2008-11-15T22:07:23Z","messageCount":62,"participants":["Pierre Habouzit","Ian Hilt","Francis Galiegue","Jeff King","Junio C Hamano","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"94388","messageId":"1225450632-7230-1-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":null,"subject":"git send-email improvements","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T10:57:09Z","receivedAt":"2008-10-31T10:57:09Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"The teaser\n==========\n\nThis series has been sent using:\n  git send-email --to git@vger.kernel.org --compose --annotate HEAD~3..\n\n\nThe series\n==========\n\nHere is a patch series to improve git send-email following our\ndiscussions at GitTogether'08, despite my hate for perl.\n\nThe first patch is a minor nitpick, because leaking fd's sucks.\n\nThe second patch allow git-send-email to receive revision lists as\narguments. This doesn't allow complex arguments combinations as it\nproces the revision lists one by one (IOW ^$sha1 $sha2 won't work as\nexpected _at all_) but this shouldn't be a problem since this command is\nprimarily used for interactive users. People wanting to use\ngit-send-email with complex revision lists through scripts MUST\ngit-format-patch first into a safe temporary directory and use\ngit-send-email on this afterwards.\n\nThe last patch adds the possibility to review patches into an editor\nbefore sending them, which allow you (thanks to patch 2) to serialize,\nreview, annotate, and send patches in one command.\n\n\nFurther discussion\n==================\n\nI think one could make git send-email better doing this:\n\n(1) make --compose and --annotate default, do not asking for a Subject\n    if it's missing, neither should we ask for the in-reply-to if it's\n    missing.\n\n    Then spawn the editor with a first empty file that contains rougly a\n    template looking like this:\n\n        ----8<----\n        GIT: Purge this buffer from any content if you don't want a series summary\n        GIT:\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        GIT:\n        GIT: Please fill a Subject if missing\n        GIT: Leave the In-Reply-To field empty if not applicable.\n        Subject:\n        In-Reply-To:\n        --> <we may want to add some more headers here: To/Cc/Bcc/...>\n\n        GIT: put the content of the mail below this line\n\n\n        GIT: [PATCH 1/10] ....  \\\n        GIT: [PATCH 2/10] ....   | this would contain all the Subject's\n        [...]                    | from the commits that are beeing sent\n        GIT: [PATCH 8/10] ....   | as a conveniency for people not\n        GIT: [PATCH 9/10] ....   | having to cut&paste them\n        GIT: [PATCH 10/10] .... /\n        ---->8----\n\n    I suggest we don't enable --compose when the series is reduced to\n    one patch, as the usual way is to comment inline. This is probably\n    arguable.\n\n(2) Introduce a --batch option that basically:\n    * turns --compose and --annotate off\n    * turns any interactive feature off\n    * complain (and fail) if it misses any information that is usually\n      asked interactively\n\nWhat do you think ?\n"},{"id":"94387","messageId":"1225450632-7230-2-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225450632-7230-1-git-send-email-madcoder@debian.org","subject":"[PATCH 1/3] git send-email: avoid leaking directory file descriptors.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T10:57:10Z","receivedAt":"2008-10-31T10:57:10Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-send-email.perl |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex bdbfac6..94ca5c8 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -374,10 +374,9 @@ for my $f (@ARGV) {\n \n \t\tpush @files, grep { -f $_ } map { +$f . \"/\" . $_ }\n \t\t\t\tsort readdir(DH);\n-\n+\t\tclosedir(DH);\n \t} elsif (-f $f or -p $f) {\n \t\tpush @files, $f;\n-\n \t} else {\n \t\tprint STDERR \"Skipping $f - not found.\\n\";\n \t}\n-- \n1.6.0.3.759.g40a2.dirty\n"},{"id":"94386","messageId":"1225450632-7230-3-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225450632-7230-2-git-send-email-madcoder@debian.org","subject":"[PATCH 2/3] git send-email: interpret unknown files as revision lists","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T10:57:11Z","receivedAt":"2008-10-31T10:57:11Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Instead of skipping unkown files on the command line, pass them through\ngit format-patch into a safe temporary directory. This allow no\ncomplicated rev-list option lists combining \"--all\" \"--not\" and so on, but\nallow to use ranges which are quite enough for most of the use cases.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-send-email.txt |    2 +-\n git-send-email.perl              |    6 ++++--\n 2 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 82f5056..cafff1a 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -8,7 +8,7 @@ git-send-email - Send a collection of patches as emails\n \n SYNOPSIS\n --------\n-'git send-email' [options] <file|directory> [... file|directory]\n+'git send-email' [options] <file|directory|rev-list>...\n \n \n DESCRIPTION\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 94ca5c8..0d50ee2 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -22,6 +22,7 @@ use Term::ReadLine;\n use Getopt::Long;\n use Data::Dumper;\n use Term::ANSIColor;\n+use File::Temp qw/ tempdir /;\n use Git;\n \n package FakeTerm;\n@@ -38,7 +39,7 @@ package main;\n \n sub usage {\n \tprint <<EOT;\n-git send-email [options] <file | directory>...\n+git send-email [options] <file | directory | rev-list >\n \n   Composing:\n     --from                  <str>  * Email From:\n@@ -378,7 +379,8 @@ for my $f (@ARGV) {\n \t} elsif (-f $f or -p $f) {\n \t\tpush @files, $f;\n \t} else {\n-\t\tprint STDERR \"Skipping $f - not found.\\n\";\n+\t\tmy $tempdir = tempdir(CLEANUP => 1);\n+\t\tpush @files, $repo->command('format-patch', '-o', $tempdir, $f);\n \t}\n }\n \n-- \n1.6.0.3.759.g40a2.dirty\n"},{"id":"94389","messageId":"1225450632-7230-4-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225450632-7230-3-git-send-email-madcoder@debian.org","subject":"[PATCH 3/3] git send-email: add --annotate option","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T10:57:12Z","receivedAt":"2008-10-31T10:57:12Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"This allows to review every patch (and fix various aspects of them, or\ncomment them) in an editor just before being sent. Combined to the fact\nthat git send-email can now process revision lists, this makes git\nsend-email and efficient way to review and send patches interactively.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-send-email.txt |   11 +++++++++++\n git-send-email.perl              |   26 ++++++++++++++++++++++++--\n 2 files changed, 35 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex cafff1a..9ee81d5 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -37,6 +37,11 @@ The --bcc option must be repeated for each user you want on the bcc list.\n +\n The --cc option must be repeated for each user you want on the cc list.\n \n+--annotate::\n+\tReview each patch you're about to send in an editor. The setting\n+\t'sendemail.multiedit' defines if this will spawn one editor per patch\n+\tor one for all of them at once.\n+\n --compose::\n \tUse $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an\n \tintroductory message for the patch series.\n@@ -204,6 +209,12 @@ sendemail.aliasfiletype::\n \tFormat of the file(s) specified in sendemail.aliasesfile. Must be\n \tone of 'mutt', 'mailrc', 'pine', or 'gnus'.\n \n+sendemail.multiedit::\n+\tIf true (default), a single editor instance will be spawned to edit\n+\tfiles you have to edit (patches when '--annotate' is used, and the\n+\tsummary when '--compose' is used). If false, files will be edited one\n+\tafter the other, spawning a new editor each time.\n+\n \n Author\n ------\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 0d50ee2..65c254d 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -48,6 +48,7 @@ git send-email [options] <file | directory | rev-list >\n     --bcc                   <str>  * Email Bcc:\n     --subject               <str>  * Email \"Subject:\"\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n+    --annotate                     * Review each patch that will be sent in an editor.\n     --compose                      * Open an editor for introduction.\n \n   Sending:\n@@ -130,7 +131,8 @@ my $compose_filename = \".msg.$$\";\n \n # Variables we fill in automatically, or via prompting:\n my (@to,@cc,@initial_cc,@bcclist,@xh,\n-\t$initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);\n+\t$initial_reply_to,$initial_subject,@files,\n+\t$author,$sender,$smtp_authpass,$annotate,$compose,$time);\n \n my $envelope_sender;\n \n@@ -151,6 +153,17 @@ if ($@) {\n # Behavior modification variables\n my ($quiet, $dry_run) = (0, 0);\n \n+# Handle interactive edition of files.\n+my $multiedit;\n+my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n+sub do_edit {\n+\tif (defined($multiedit) && !$multiedit) {\n+\t\tmap { system('sh', '-c', $editor.' \"$@\"', $editor, $_); } @_;\n+\t} else {\n+\t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, @_);\n+\t}\n+}\n+\n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);\n my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);\n@@ -180,6 +193,7 @@ my %config_settings = (\n     \"aliasesfile\" => \\@alias_files,\n     \"suppresscc\" => \\@suppress_cc,\n     \"envelopesender\" => \\$envelope_sender,\n+    \"multiedit\" => \\$multiedit,\n );\n \n # Handle Uncouth Termination\n@@ -222,6 +236,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"smtp-ssl\" => sub { $smtp_encryption = 'ssl' },\n \t\t    \"smtp-encryption=s\" => \\$smtp_encryption,\n \t\t    \"identity=s\" => \\$identity,\n+\t\t    \"annotate\" => \\$annotate,\n \t\t    \"compose\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n@@ -499,7 +514,12 @@ EOT\n \tclose(C);\n \n \tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n-\tsystem('sh', '-c', $editor.' \"$@\"', $editor, $compose_filename);\n+\n+\tif ($annotate) {\n+\t\tdo_edit($compose_filename, @files);\n+\t} else {\n+\t\tdo_edit($compose_filename);\n+\t}\n \n \topen(C2,\">\",$compose_filename . \".final\")\n \t\tor die \"Failed to open $compose_filename.final : \" . $!;\n@@ -548,6 +568,8 @@ EOT\n \t}\n \n \t@files = ($compose_filename . \".final\", @files);\n+} elsif ($annotate) {\n+\tdo_edit(@files);\n }\n \n # Variables we set as part of the loop over files\n-- \n1.6.0.3.759.g40a2.dirty\n"},{"id":"94398","messageId":"1225456609-694-1-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225450632-7230-1-git-send-email-madcoder@debian.org","subject":"Further enhancement proposal for git-send-email","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T12:36:46Z","receivedAt":"2008-10-31T12:36:46Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Here is a three patch series (again).\n\n[PATCH 1/3] git send-email: make the message file name more specific.\n  -> quite independant, and should IMHO be taken.\n\n\n[PATCH 2/3] git send-email: do not ask questions when --compose is used.\n[PATCH 3/3] git send-email: turn --compose on when more than one patch.\n\n  Those two patches enhance git-send-email by making ask less questions\n  when --compose is used (as it can grab the subject, from and reply-to\n  from the buffer).\n\n  It also turns --compose on by default as soon as there is more than\n  one patch, as I believe than commenting a patch series is more often\n  done than not. It's is really trivial to \"refuse\" to comment the\n  series by just erasing the full buffer content, which should not\n  really be too anoying (or one can explicitely pass --no-compose for\n  the same result).\n\n  It's probable that those two changes may trigger some discussion\n  though, but I just used that to send this series, and I can tell with\n  this git-send-email is nearer what I would like it to be.\n"},{"id":"94397","messageId":"1225456609-694-2-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225456609-694-1-git-send-email-madcoder@debian.org","subject":"[PATCH 1/3] git send-email: make the message file name more specific.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T12:36:47Z","receivedAt":"2008-10-31T12:36:47Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"This helps editors choosing their syntax hilighting properly.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-send-email.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 65c254d..4ca571f 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -127,7 +127,7 @@ sub unique_email_list(@);\n sub cleanup_compose_files();\n \n # Constants (essentially)\n-my $compose_filename = \".msg.$$\";\n+my $compose_filename = \".gitsendemail.msg.$$\";\n \n # Variables we fill in automatically, or via prompting:\n my (@to,@cc,@initial_cc,@bcclist,@xh,\n-- \n1.6.0.3.763.g0275.dirty\n"},{"id":"94399","messageId":"1225456609-694-3-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225456609-694-2-git-send-email-madcoder@debian.org","subject":"[PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T12:36:48Z","receivedAt":"2008-10-31T12:36:48Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"When --compose is used, we can grab the From/Subject/In-Reply-To from the\nedited summary, let it be so and don't ask the user silly questions.\n\nThe summary templates gets quite revamped, and includes the list of\npatches subjects that are going to be sent with this batch.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-send-email.perl |  174 ++++++++++++++++++++++++++++++---------------------\n 1 files changed, 102 insertions(+), 72 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 4ca571f..5c189a7 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -417,6 +417,105 @@ if (@files) {\n \tusage();\n }\n \n+sub get_patch_subject($) {\n+\tmy $fn = shift;\n+\topen (my $fh, '<', $fn);\n+\twhile (my $line = <$fh>) {\n+\t\tnext unless ($line =~ /^Subject: (.*)$/);\n+\t\tclose $fh;\n+\t\treturn \"GIT: $1\\n\";\n+\t}\n+\tclose $fh;\n+\tdie \"No subject line in $fn ?\";\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+\n+\n+\tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n+\tmy $tpl_subject = $initial_subject || '';\n+\tmy $tpl_reply_to = $initial_reply_to || '';\n+\n+\tprint C <<EOT;\n+From $tpl_sender # This line is ignored.\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+From: $tpl_sender\n+Subject: $tpl_subject\n+In-Reply-To: $tpl_reply_to\n+\n+GIT: Please enter your email below this line.\n+\n+EOT\n+\tfor my $f (@files) {\n+\t\tprint C get_patch_subject($f);\n+\t}\n+\tclose(C);\n+\n+\tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n+\n+\tif ($annotate) {\n+\t\tdo_edit($compose_filename, @files);\n+\t} else {\n+\t\tdo_edit($compose_filename);\n+\t}\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+\tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n+\tmy $in_body = 0;\n+\tmy $summary_empty = 1;\n+\twhile(<C>) {\n+\t\tnext if m/^GIT: /;\n+\t\tif ($in_body) {\n+\t\t} elsif (/^\\n$/) {\n+\t\t\t$in_body = 1;\n+\t\t\tif ($need_8bit_cte) {\n+\t\t\t\tprint C2 \"MIME-Version: 1.0\\n\",\n+\t\t\t\t\t \"Content-Type: text/plain; \",\n+\t\t\t\t\t   \"charset=utf-8\\n\",\n+\t\t\t\t\t \"Content-Transfer-Encoding: 8bit\\n\";\n+\t\t\t}\n+\t\t} elsif (/^MIME-Version:/i) {\n+\t\t\t$need_8bit_cte = 0;\n+\t\t} elsif (/^Subject:\\s*(.+)\\s*$/i) {\n+\t\t\t$initial_subject = $1;\n+\t\t\tmy $subject = $initial_subject;\n+\t\t\t$_ = \"Subject: \" .\n+\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n+\t\t\t\t quote_rfc2047($subject) :\n+\t\t\t\t $subject) .\n+\t\t\t\t\"\\n\";\n+\t\t} elsif (/^In-Reply-To:\\s*(.+)\\s*$/i) {\n+\t\t\t$initial_reply_to = $1;\n+\t\t\tnext;\n+\t\t} elsif (/^From:\\s*(.+)\\s*$/i) {\n+\t\t\t$sender = $1;\n+\t\t\tnext;\n+\t\t}\n+\t\t$summary_empty = 0;\n+\t\tprint C2 $_;\n+\t}\n+\tclose(C);\n+\tclose(C2);\n+\n+\tif ($summary_empty) {\n+\t\tprint \"Summary email is empty, skpping it\\n\";\n+\t\t$compose = -1;\n+\t}\n+} elsif ($annotate) {\n+\tdo_edit(@files);\n+}\n+\n my $prompting = 0;\n if (!defined $sender) {\n \t$sender = $repoauthor || $repocommitter || '';\n@@ -461,17 +560,6 @@ sub expand_aliases {\n @initial_cc = expand_aliases(@initial_cc);\n @bcclist = expand_aliases(@bcclist);\n \n-if (!defined $initial_subject && $compose) {\n-\twhile (1) {\n-\t\t$_ = $term->readline(\"What subject should the initial email start with? \", $initial_subject);\n-\t\tlast if defined $_;\n-\t\tprint \"\\n\";\n-\t}\n-\n-\t$initial_subject = $_;\n-\t$prompting++;\n-}\n-\n if ($thread && !defined $initial_reply_to && $prompting) {\n \twhile (1) {\n \t\t$_= $term->readline(\"Message-ID to be used as In-Reply-To for the first email? \", $initial_reply_to);\n@@ -498,64 +586,6 @@ if (!defined $smtp_server) {\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 $sender # This line is ignored.\\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{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n-\n-\tif ($annotate) {\n-\t\tdo_edit($compose_filename, @files);\n-\t} else {\n-\t\tdo_edit($compose_filename);\n-\t}\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-\tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n-\tmy $in_body = 0;\n-\twhile(<C>) {\n-\t\tnext if m/^GIT: /;\n-\t\tif (!$in_body && /^\\n$/) {\n-\t\t\t$in_body = 1;\n-\t\t\tif ($need_8bit_cte) {\n-\t\t\t\tprint C2 \"MIME-Version: 1.0\\n\",\n-\t\t\t\t\t \"Content-Type: text/plain; \",\n-\t\t\t\t\t   \"charset=utf-8\\n\",\n-\t\t\t\t\t \"Content-Transfer-Encoding: 8bit\\n\";\n-\t\t\t}\n-\t\t}\n-\t\tif (!$in_body && /^MIME-Version:/i) {\n-\t\t\t$need_8bit_cte = 0;\n-\t\t}\n-\t\tif (!$in_body && /^Subject: ?(.*)/i) {\n-\t\t\tmy $subject = $1;\n-\t\t\t$_ = \"Subject: \" .\n-\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n-\t\t\t\t quote_rfc2047($subject) :\n-\t\t\t\t $subject) .\n-\t\t\t\t\"\\n\";\n-\t\t}\n-\t\tprint C2 $_;\n-\t}\n-\tclose(C);\n-\tclose(C2);\n-\n \twhile (1) {\n \t\t$_ = $term->readline(\"Send this email? (y|n) \");\n \t\tlast if defined $_;\n@@ -567,9 +597,9 @@ EOT\n \t\texit(0);\n \t}\n \n-\t@files = ($compose_filename . \".final\", @files);\n-} elsif ($annotate) {\n-\tdo_edit(@files);\n+\tif ($compose > 0) {\n+\t\t@files = ($compose_filename . \".final\", @files);\n+\t}\n }\n \n # Variables we set as part of the loop over files\n-- \n1.6.0.3.763.g0275.dirty\n"},{"id":"94400","messageId":"1225456609-694-4-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225456609-694-3-git-send-email-madcoder@debian.org","subject":"[PATCH 3/3] git send-email: turn --compose on when more than one patch.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T12:36:49Z","receivedAt":"2008-10-31T12:36:49Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Automatically turn --compose on when there is more than one patch, and\nthat the output is a tty.\n\nDo not print the list of files sent anymore in that case, as the list is\nshown in the summary editor.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-send-email.perl |   10 +++++++---\n 1 files changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 5c189a7..5cebb40 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -49,7 +49,7 @@ git send-email [options] <file | directory | rev-list >\n     --subject               <str>  * Email \"Subject:\"\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n     --annotate                     * Review each patch that will be sent in an editor.\n-    --compose                      * Open an editor for introduction.\n+    --[no-]compose                 * Open an editor for introduction.\n \n   Sending:\n     --envelope-sender       <str>  * Email envelope sender.\n@@ -237,7 +237,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"smtp-encryption=s\" => \\$smtp_encryption,\n \t\t    \"identity=s\" => \\$identity,\n \t\t    \"annotate\" => \\$annotate,\n-\t\t    \"compose\" => \\$compose,\n+\t\t    \"compose!\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n \t\t    \"suppress-from!\" => \\$suppress_from,\n@@ -409,7 +409,11 @@ if ($validate) {\n }\n \n if (@files) {\n-\tunless ($quiet) {\n+\tif (!defined($compose) && -t STDOUT) {\n+\t\t# turn $compose on if there is more than one file\n+\t\t$compose = $#files;\n+\t}\n+\tunless ($quiet || $compose) {\n \t\tprint $_,\"\\n\" for (@files);\n \t}\n } else {\n-- \n1.6.0.3.763.g0275.dirty\n"},{"id":"94420","messageId":"1225471925-2750-1-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225450632-7230-3-git-send-email-madcoder@debian.org","subject":"[PATCH] git send-email: allow any rev-list option as an argument.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T16:52:05Z","receivedAt":"2008-10-31T16:52:05Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n\n  One can consider to squash that on top of\n  <1225450632-7230-3-git-send-email-madcoder@debian.org> to be able to pass\n  all non path arguments before a possible '--' to git format-patch.\n\n  The downside of this patch is that:\n\n    git send-email -C -C -M origin/next\n\n  will send the content of origin/next if it's an existing file. Of course a\n  disambiguation can be:\n\n    git send-email -C -C -M refs/heads/origin/next\n\n  But again if this file also exists, one is basically screwed. I see no\n  proper way to fix that, unless to change git-send-email behaviour at once.\n\n\n  Though I believe this semantics to be better than the one in the previous\n  patch, as it's often a good idea to pass -M -C -C to format-patch, which is\n  currently impossible. It also allow revision lists to work as expected (wrt\n  --all, --not and so on).\n\n  Comments are welcomed.\n\n\n Documentation/git-send-email.txt |    2 +-\n git-send-email.perl              |   19 ++++++++++++++-----\n 2 files changed, 15 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 9ee81d5..39d6da9 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -8,7 +8,7 @@ git-send-email - Send a collection of patches as emails\n \n SYNOPSIS\n --------\n-'git send-email' [options] <file|directory|rev-list>...\n+'git send-email' [options] <file|directory|rev-list options>...\n \n \n DESCRIPTION\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 5c189a7..8667e0b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -25,6 +25,8 @@ use Term::ANSIColor;\n use File::Temp qw/ tempdir /;\n use Git;\n \n+Getopt::Long::Configure qw/ pass_through /;\n+\n package FakeTerm;\n sub new {\n \tmy ($class, $reason) = @_;\n@@ -39,7 +41,7 @@ package main;\n \n sub usage {\n \tprint <<EOT;\n-git send-email [options] <file | directory | rev-list >\n+git send-email [options] <file | directory | rev-list options >\n \n   Composing:\n     --from                  <str>  * Email From:\n@@ -383,8 +385,12 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\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-\tif (-d $f) {\n+my @rev_list_opts;\n+while (my $f = pop @ARGV) {\n+\tif ($f eq \"--\") {\n+\t\tpush @rev_list_opts, \"--\", @ARGV;\n+\t\t@ARGV = ();\n+\t} elsif (-d $f) {\n \t\topendir(DH,$f)\n \t\t\tor die \"Failed to opendir $f: $!\";\n \n@@ -394,11 +400,14 @@ for my $f (@ARGV) {\n \t} elsif (-f $f or -p $f) {\n \t\tpush @files, $f;\n \t} else {\n-\t\tmy $tempdir = tempdir(CLEANUP => 1);\n-\t\tpush @files, $repo->command('format-patch', '-o', $tempdir, $f);\n+\t\tpush @rev_list_opts, $f;\n \t}\n }\n \n+if (@rev_list_opts) {\n+\tpush @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);\n+}\n+\n if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\n-- \n1.6.0.3.791.g15769.dirty\n"},{"id":"94463","messageId":"20081031213338.GB21345@maintenance05.msc.mcgregor-surmount.com","threadId":"16108","inReplyTo":"1225456609-694-3-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Ian Hilt","fromEmail":"ihilt@mcgregor-surmount.com","sentAt":"2008-10-31T21:33:38Z","receivedAt":"2008-10-31T21:33:38Z","isPatch":true,"sender":{"key":"ihilt@mcgregor-surmount.com","avatar":null},"body":"On Fri, Oct 31, 2008 at 01:36:48PM +0100, Pierre Habouzit wrote:\n> +GIT: Please enter your email below this line.\n\nAt first glance I thought this meant to enter my email address here.\nSo, instead of \"email\" would \"message\" be better?  Although on second\nglance I realized this is where the body of the message went.  Not sure\nif this is worth changing.\n\n\tIan\n"},{"id":"94464","messageId":"20081031213403.GC21345@maintenance05.msc.mcgregor-surmount.com","threadId":"16108","inReplyTo":"1225450632-7230-4-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 3/3] git send-email: add --annotate option","fromName":"Ian Hilt","fromEmail":"ihilt@mcgregor-surmount.com","sentAt":"2008-10-31T21:34:03Z","receivedAt":"2008-10-31T21:34:03Z","isPatch":true,"sender":{"key":"ihilt@mcgregor-surmount.com","avatar":null},"body":"On Fri, Oct 31, 2008 at 11:57:12AM +0100, Pierre Habouzit wrote:\n> This allows to review every patch (and fix various aspects of them, or\n> comment them) in an editor just before being sent. Combined to the fact\n> that git send-email can now process revision lists, this makes git\n> send-email and efficient way to review and send patches interactively.\n> \n> Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n> ---\n>  Documentation/git-send-email.txt |   11 +++++++++++\n>  git-send-email.perl              |   26 ++++++++++++++++++++++++--\n>  2 files changed, 35 insertions(+), 2 deletions(-)\n> \n> diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\n> index cafff1a..9ee81d5 100644\n> --- a/Documentation/git-send-email.txt\n> +++ b/Documentation/git-send-email.txt\n> @@ -37,6 +37,11 @@ The --bcc option must be repeated for each user you want on the bcc list.\n>  +\n>  The --cc option must be repeated for each user you want on the cc list.\n>  \n> +--annotate::\n> +\tReview each patch you're about to send in an editor. The setting\n> +\t'sendemail.multiedit' defines if this will spawn one editor per patch\n> +\tor one for all of them at once.\n> +\n>  --compose::\n>  \tUse $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an\n>  \tintroductory message for the patch series.\n> @@ -204,6 +209,12 @@ sendemail.aliasfiletype::\n>  \tFormat of the file(s) specified in sendemail.aliasesfile. Must be\n>  \tone of 'mutt', 'mailrc', 'pine', or 'gnus'.\n>  \n> +sendemail.multiedit::\n> +\tIf true (default), a single editor instance will be spawned to edit\n> +\tfiles you have to edit (patches when '--annotate' is used, and the\n> +\tsummary when '--compose' is used). If false, files will be edited one\n> +\tafter the other, spawning a new editor each time.\n> +\n>  \n>  Author\n>  ------\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 0d50ee2..65c254d 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -48,6 +48,7 @@ git send-email [options] <file | directory | rev-list >\n>      --bcc                   <str>  * Email Bcc:\n>      --subject               <str>  * Email \"Subject:\"\n>      --in-reply-to           <str>  * Email \"In-Reply-To:\"\n> +    --annotate                     * Review each patch that will be sent in an editor.\n>      --compose                      * Open an editor for introduction.\n>  \n>    Sending:\n> @@ -130,7 +131,8 @@ my $compose_filename = \".msg.$$\";\n>  \n>  # Variables we fill in automatically, or via prompting:\n>  my (@to,@cc,@initial_cc,@bcclist,@xh,\n> -\t$initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);\n> +\t$initial_reply_to,$initial_subject,@files,\n> +\t$author,$sender,$smtp_authpass,$annotate,$compose,$time);\n>  \n>  my $envelope_sender;\n>  \n> @@ -151,6 +153,17 @@ if ($@) {\n>  # Behavior modification variables\n>  my ($quiet, $dry_run) = (0, 0);\n>  \n> +# Handle interactive edition of files.\n\ns/edition/editing/;\n"},{"id":"94465","messageId":"20081031213803.GB21799@artemis.corp","threadId":"16108","inReplyTo":"20081031213338.GB21345@maintenance05.msc.mcgregor-surmount.com","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-10-31T21:38:03Z","receivedAt":"2008-10-31T21:38:03Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Fri, Oct 31, 2008 at 09:33:38PM +0000, Ian Hilt wrote:\n> On Fri, Oct 31, 2008 at 01:36:48PM +0100, Pierre Habouzit wrote:\n> > +GIT: Please enter your email below this line.\n> \n> At first glance I thought this meant to enter my email address here.\n> So, instead of \"email\" would \"message\" be better?  Although on second\n> glance I realized this is where the body of the message went.  Not sure\n> if this is worth changing.\n\nWell, this line sounds kind of awkward actually, so I was even thinking\nabout removing it.\n\nDecent editors should probably have a plugin to put the cursor here and\nbe done with it.\n\n\nIn fact what looks odd is the GIT: stuff. a line looking like:\n\n    --- write your message below this line ---\n\nLooks 10x better, though need some code to strip it out if the user kept\nit, and I'm lazy, GIT: stuff is automatically removed...\n\n\nBut if that's the only thing that you don't like in the series, I'm\nglad, this is quite a minor issue ;)\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94473","messageId":"20081031220149.GD21345@maintenance05.msc.mcgregor-surmount.com","threadId":"16108","inReplyTo":"20081031213803.GB21799@artemis.corp","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Ian Hilt","fromEmail":"ihilt@mcgregor-surmount.com","sentAt":"2008-10-31T22:01:49Z","receivedAt":"2008-10-31T22:01:49Z","isPatch":true,"sender":{"key":"ihilt@mcgregor-surmount.com","avatar":null},"body":"On Fri, Oct 31, 2008 at 10:38:03PM +0100, Pierre Habouzit wrote:\n> On Fri, Oct 31, 2008 at 09:33:38PM +0000, Ian Hilt wrote:\n> > On Fri, Oct 31, 2008 at 01:36:48PM +0100, Pierre Habouzit wrote:\n> > > +GIT: Please enter your email below this line.\n> > \n> > At first glance I thought this meant to enter my email address here.\n> > So, instead of \"email\" would \"message\" be better?  Although on second\n> > glance I realized this is where the body of the message went.  Not sure\n> > if this is worth changing.\n> \n> Well, this line sounds kind of awkward actually, so I was even thinking\n> about removing it.\n> \n> Decent editors should probably have a plugin to put the cursor here and\n> be done with it.\n> \n> \n> In fact what looks odd is the GIT: stuff. a line looking like:\n> \n>     --- write your message below this line ---\n> \n> Looks 10x better, though need some code to strip it out if the user kept\n> it, and I'm lazy, GIT: stuff is automatically removed...\n\nOr, to follow the convention of git-status and git-commit, you could do\nthis with \"# \".\n\nSo something like,\n\n--->8---\nFrom: Ian Hilt <ihilt@mcgregor-surmount.com>\nDate: Fri, 31 Oct 2008 17:55:46 -0400\nSubject: [PATCH] Use a hash instead of GIT: for line removal\n\nSigned-off-by: Ian Hilt <ihilt@mcgregor-surmount.com>\n---\n git-send-email.perl |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 5cebb40..c6e21a8 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -427,7 +427,7 @@ sub get_patch_subject($) {\n \twhile (my $line = <$fh>) {\n \t\tnext unless ($line =~ /^Subject: (.*)$/);\n \t\tclose $fh;\n-\t\treturn \"GIT: $1\\n\";\n+\t\treturn \"# $1\\n\";\n \t}\n \tclose $fh;\n \tdie \"No subject line in $fn ?\";\n@@ -446,14 +446,14 @@ if ($compose) {\n \n \tprint C <<EOT;\n From $tpl_sender # This line is ignored.\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+# Lines beginning in \"# \" will be removed.\n+# Consider including an overall diffstat or table of contents\n+# for the patch you are writing.\n From: $tpl_sender\n Subject: $tpl_subject\n In-Reply-To: $tpl_reply_to\n \n-GIT: Please enter your email below this line.\n+# --- write your message below this line ---\n \n EOT\n \tfor my $f (@files) {\n@@ -479,7 +479,7 @@ EOT\n \tmy $in_body = 0;\n \tmy $summary_empty = 1;\n \twhile(<C>) {\n-\t\tnext if m/^GIT: /;\n+\t\tnext if m/^# /;\n \t\tif ($in_body) {\n \t\t} elsif (/^\\n$/) {\n \t\t\t$in_body = 1;\n--->8---\n\n> But if that's the only thing that you don't like in the series, I'm\n> glad, this is quite a minor issue ;)\n\nI've thought something like this would be a good thing.  An editor makes\nthings easier to fix than the command-line.\n\n\tIan\n"},{"id":"94531","messageId":"20081101022649.GB17961@sys-0.hiltweb.site","threadId":"16108","inReplyTo":"20081031220149.GD21345@maintenance05.msc.mcgregor-surmount.com","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Ian Hilt","fromEmail":"ian.hilt@gmx.com","sentAt":"2008-11-01T02:26:49Z","receivedAt":"2008-11-01T02:26:49Z","isPatch":true,"sender":{"key":"ian.hilt@gmx.com","avatar":null},"body":"On Fri, Oct 31, 2008 at 06:01:49PM -0400, Ian Hilt wrote:\n> I've thought something like this would be a good thing.  An editor makes\n> things easier to fix than the command-line.\n\nSpeaking of which, maybe let's add the To field to the list.\n\n--->8---\nFrom: Ian Hilt <ian.hilt@gmx.com>\nDate: Fri, 31 Oct 2008 22:15:46 -0400\nSubject: [PATCH] git-send-email.perl: add To field in editor\n\nThis allows the compose mode to add the To field in the editor.  However\nit currently will not remove an address.\n\nSigned-off-by: Ian Hilt <ian.hilt@gmx.com>\n---\n\nThis is on top of the previous patch I sent.\n\n git-send-email.perl |   12 +++++++++++-\n 1 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 0944be7..ed95402 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -450,6 +450,12 @@ if ($compose) {\n \n \n \tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n+\tmy @tpl_to;\n+\tif (@to) {\n+\t\tforeach my $i (0..$#to) {\n+\t\t\t$tpl_to[$i] = $to[$i];\n+\t\t}\n+\t}\n \tmy $tpl_subject = $initial_subject || '';\n \tmy $tpl_reply_to = $initial_reply_to || '';\n \n@@ -459,6 +465,7 @@ From $tpl_sender # This line is ignored.\n # Consider including an overall diffstat or table of contents\n # for the patch you are writing.\n From: $tpl_sender\n+To: @tpl_to\n Subject: $tpl_subject\n In-Reply-To: $tpl_reply_to\n \n@@ -514,6 +521,9 @@ EOT\n \t\t} elsif (/^From:\\s*(.+)\\s*$/i) {\n \t\t\t$sender = $1;\n \t\t\tnext;\n+\t\t} elsif (/^To:\\s*(.+)\\s*$/i) {\n+\t\t\tpush @to, $1;\n+\t\t\tnext;\n \t\t}\n \t\t$summary_empty = 0;\n \t\tprint C2 $_;\n@@ -522,7 +532,7 @@ EOT\n \tclose(C2);\n \n \tif ($summary_empty) {\n-\t\tprint \"Summary email is empty, skpping it\\n\";\n+\t\tprint \"Summary email is empty, skipping it\\n\";\n \t\t$compose = -1;\n \t}\n } elsif ($annotate) {\n-- \n1.6.0.3.523.g304d0\n"},{"id":"94546","messageId":"20081101110439.GB3819@artemis.corp","threadId":"16108","inReplyTo":"20081101022649.GB17961@sys-0.hiltweb.site","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-01T11:04:39Z","receivedAt":"2008-11-01T11:04:39Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sat, Nov 01, 2008 at 02:26:49AM +0000, Ian Hilt wrote:\n> On Fri, Oct 31, 2008 at 06:01:49PM -0400, Ian Hilt wrote:\n> > I've thought something like this would be a good thing.  An editor makes\n> > things easier to fix than the command-line.\n> \n> Speaking of which, maybe let's add the To field to the list.\n\nI didn't do it for a very good reason: the To field is tricker to parse\nbecause very fast it's multiline, and must be split along the ',' when\nparsed back and so on.\n\nAnd even moreuseful than the To is the Cc list that git-send-email\nbloats to death and that I would like to reduce very often.\n\nBut sadly that needs an expertise of perl I absolutely don't have. We\nprobably even want to depend on some MIME perl library that knows about\nthose kind of issues and do it for us well.\n\nBut yeah, I knew I left out those, and this was the reason.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94556","messageId":"20081101130033.GD17961@sys-0.hiltweb.site","threadId":"16108","inReplyTo":"20081101110439.GB3819@artemis.corp","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Ian Hilt","fromEmail":"ian.hilt@gmx.com","sentAt":"2008-11-01T13:00:33Z","receivedAt":"2008-11-01T13:00:33Z","isPatch":true,"sender":{"key":"ian.hilt@gmx.com","avatar":null},"body":"On Sat, Nov 01, 2008 at 12:04:39PM +0100, Pierre Habouzit wrote:\n> I didn't do it for a very good reason: the To field is tricker to parse\n> because very fast it's multiline, and must be split along the ',' when\n> parsed back and so on.\n\nRight.  So my patch is broken in that it doesn't parse the addresses\ncorrectly.  This _should_ be easy to fix.  I knew my patch sucked, but I\nwanted to get the idea out there.  For me, I don't like specifying all\nthat information on the command-line.  It would be nice to be able to\nedit the To and Cc fields in the editor.\n\n> And even moreuseful than the To is the Cc list that git-send-email\n> bloats to death and that I would like to reduce very often.\n\nYou mean git-send-email adds too many addresses to the Cc list, or the\ncode for those fields is already bloated to death?\n\n> But sadly that needs an expertise of perl I absolutely don't have. We\n> probably even want to depend on some MIME perl library that knows about\n> those kind of issues and do it for us well.\n\nI'm confused here.  Why would a MIME library help?\n\n> But yeah, I knew I left out those, and this was the reason.\n\nAnyway, do you, or does anyone else, think it's even worth coding the\npossibility for the user to edit the To and Cc fields?\n\n\n\tIan\n"},{"id":"94564","messageId":"20081101170817.GC26229@artemis.corp","threadId":"16108","inReplyTo":"20081101130033.GD17961@sys-0.hiltweb.site","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-01T17:08:17Z","receivedAt":"2008-11-01T17:08:17Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sat, Nov 01, 2008 at 01:00:33PM +0000, Ian Hilt wrote:\n> On Sat, Nov 01, 2008 at 12:04:39PM +0100, Pierre Habouzit wrote:\n> > I didn't do it for a very good reason: the To field is tricker to parse\n> > because very fast it's multiline, and must be split along the ',' when\n> > parsed back and so on.\n> \n> Right.  So my patch is broken in that it doesn't parse the addresses\n> correctly.  This _should_ be easy to fix.  I knew my patch sucked, but I\n> wanted to get the idea out there.  For me, I don't like specifying all\n> that information on the command-line.  It would be nice to be able to\n> edit the To and Cc fields in the editor.\n> \n> > And even moreuseful than the To is the Cc list that git-send-email\n> > bloats to death and that I would like to reduce very often.\n> \n> You mean git-send-email adds too many addresses to the Cc list, or the\n> code for those fields is already bloated to death?\n\nThe former, I've not looked at the code I can't really say.\n\n> > But sadly that needs an expertise of perl I absolutely don't have. We\n> > probably even want to depend on some MIME perl library that knows about\n> > those kind of issues and do it for us well.\n> \n> I'm confused here.  Why would a MIME library help?\n\nHmm maybe I'm wrong, but the idea would be to do what mutt does and be\nable to parse:\n\nTo: John Doe <some.address@some.tld>, Random Joe <random.joe@abc.def>,\n  Superman <batman@nyc.us>,\n  \"Someone with a comma, inside its tag name\" <a@b.com>\n\nAnd that needs to know how to do that with perl, and _really_ I hate\nperl enough for not being able to do that well. Splitting on ',' is just\nnot going to fly.\n\n> > But yeah, I knew I left out those, and this was the reason.\n> \n> Anyway, do you, or does anyone else, think it's even worth coding the\n> possibility for the user to edit the To and Cc fields?\n\n*YES*\n\nI would love to see git-send-email work like mutt does: it fills the\nfield like it does now, and you are allowed to fix that, and it parses\nthe buffer back to guess what you wanted. It allow to drop most of the\ninteractive prompting that is so annoying (since it's not in-shell and\nhas no history and stuff like that, unlike my $EDITOR).\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94567","messageId":"200811011834.32702.fg@one2team.com","threadId":"16108","inReplyTo":"20081101170817.GC26229@artemis.corp","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Francis Galiegue","fromEmail":"fg@one2team.com","sentAt":"2008-11-01T17:34:32Z","receivedAt":"2008-11-01T17:34:32Z","isPatch":true,"sender":{"key":"fg@one2team.com","avatar":null},"body":"Le Saturday 01 November 2008 18:08:17 Pierre Habouzit, vous avez écrit :\n[...]\n>\n> To: John Doe <some.address@some.tld>, Random Joe <random.joe@abc.def>,\n>   Superman <batman@nyc.us>,\n>   \"Someone with a comma, inside its tag name\" <a@b.com>\n>\n\nfg@erwin ~ $ cat t.txt\nTo: John Doe <some.address@some.tld>, Random Joe <random.joe@abc.def>, \nSuperman <batman@nyc.us>, \"Someone with a comma, inside its tag name\" \n<a@b.com>\nfg@erwin ~ $ <t.txt perl -ne 's,^To:\\s*,,i; @mails = m/\\s*((?:\"[^\"]+\")?\n\\s*<[^@]+@[^@]+>)\\s*,?/g; END { print join(\"\\n\", @mails) . \"\\n\"}'\n<some.address@some.tld>\n<random.joe@abc.def>\n<batman@nyc.us>\n\"Someone with a comma, inside its tag name\" <a@b.com>\n\nThat's regex, not especially perl ;)\n\n-- \nFrancis Galiegue\nONE2TEAM\nIngénieur système\nMob : +33 (0) 6 83 87 78 75\nTel : +33 (0) 1 78 94 55 52\nfge@one2team.com\n40 avenue Raymond Poincaré\n75116 Paris\n"},{"id":"94568","messageId":"20081101174352.GG26229@artemis.corp","threadId":"16108","inReplyTo":"200811011834.32702.fg@one2team.com","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-01T17:43:52Z","receivedAt":"2008-11-01T17:43:52Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sat, Nov 01, 2008 at 05:34:32PM +0000, Francis Galiegue wrote:\n> Le Saturday 01 November 2008 18:08:17 Pierre Habouzit, vous avez écrit :\n> [...]\n> >\n> > To: John Doe <some.address@some.tld>, Random Joe <random.joe@abc.def>,\n> >   Superman <batman@nyc.us>,\n> >   \"Someone with a comma, inside its tag name\" <a@b.com>\n> >\n> \n> fg@erwin ~ $ cat t.txt\n> To: John Doe <some.address@some.tld>, Random Joe <random.joe@abc.def>, \n> Superman <batman@nyc.us>, \"Someone with a comma, inside its tag name\" \n> <a@b.com>\n> fg@erwin ~ $ <t.txt perl -ne 's,^To:\\s*,,i; @mails = m/\\s*((?:\"[^\"]+\")?\n> \\s*<[^@]+@[^@]+>)\\s*,?/g; END { print join(\"\\n\", @mails) . \"\\n\"}'\n> <some.address@some.tld>\n> <random.joe@abc.def>\n> <batman@nyc.us>\n> \"Someone with a comma, inside its tag name\" <a@b.com>\n> \n> That's regex, not especially perl ;)\n\nYour regex fails to parse:\n\n\"Someone with a comma, and an escape double quote \\\" in its name\"\n  <regex.cant.be.used.for.serious.parsing@i.told.you.so>\n\nThat's why I first hinted at some MIME library that has probably made\nthat right.\n\nNot to mention that you don't fix the multiline issue, but that is quite\nless of a problem, it merely needs an accumulator and a 1 line lookahead\nin the parser code while in the header parts. Nothing unrealistic for me\nto write.\n\nBut I just can't resolve myself to parse anything with regex because I\njust know it's horribly broken and wrong.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94570","messageId":"alpine.LFD.2.00.0811011323240.23340@sys-0.hiltweb.site","threadId":"16108","inReplyTo":"20081101170817.GC26229@artemis.corp","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Ian Hilt","fromEmail":"ian.hilt@gmx.com","sentAt":"2008-11-01T17:54:55Z","receivedAt":"2008-11-01T17:54:55Z","isPatch":true,"sender":{"key":"ian.hilt@gmx.com","avatar":null},"body":"On Sat, 1 Nov 2008, Pierre Habouzit wrote:\n> On Sat, Nov 01, 2008 at 01:00:33PM +0000, Ian Hilt wrote:\n> > I'm confused here.  Why would a MIME library help?\n> \n> Hmm maybe I'm wrong, but the idea would be to do what mutt does and be\n> able to parse:\n> \n> To: John Doe <some.address@some.tld>, Random Joe <random.joe@abc.def>,\n>   Superman <batman@nyc.us>,\n>   \"Someone with a comma, inside its tag name\" <a@b.com>\n\nNo, you're absolutely right for this reason: MIME-encoded addresses.\n\nUgh.\n\nAlthough, to my knowledge, git-send-email doesn't understand that now. \nSo unless we want to support MIME-encoded addresses, this won't be\nnecessary.\n\n> And that needs to know how to do that with perl, and _really_ I hate\n> perl enough for not being able to do that well. Splitting on ',' is just\n> not going to fly.\n\nYea, it's going to be a bit trickier than that.\n\n> > > But yeah, I knew I left out those, and this was the reason.\n> > \n> > Anyway, do you, or does anyone else, think it's even worth coding the\n> > possibility for the user to edit the To and Cc fields?\n> \n> *YES*\n> \n> I would love to see git-send-email work like mutt does: it fills the\n> field like it does now, and you are allowed to fix that, and it parses\n> the buffer back to guess what you wanted. It allow to drop most of the\n> interactive prompting that is so annoying (since it's not in-shell and\n> has no history and stuff like that, unlike my $EDITOR).\n\nHmm, I'll look into this; especially the MIME library.  I'm not a perl\nmonk, but I can give it a shot, no?\n\n\n\tIan\n"},{"id":"94582","messageId":"200811012056.37220.fg@one2team.net","threadId":"16108","inReplyTo":"20081101174352.GG26229@artemis.corp","subject":"Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.","fromName":"Francis Galiegue","fromEmail":"fg@one2team.net","sentAt":"2008-11-01T19:56:37Z","receivedAt":"2008-11-01T19:56:37Z","isPatch":true,"sender":{"key":"fg@one2team.net","avatar":null},"body":"Le Saturday 01 November 2008 18:43:52 Pierre Habouzit, vous avez écrit :\n[...]\n\n> Your regex fails to parse:\n>\n> \"Someone with a comma, and an escape double quote \\\" in its name\"\n\nEasy fix: replace \"[^\"]+\" with \"[^\"]+(?:\\\\\"[^\"]*)*\".\n\n>   <regex.cant.be.used.for.serious.parsing@i.told.you.so>\n\nOh yes. Regexes _are_ the way to do serious parsing. All MIME packages you \nwill find floating around use regexes to parse mail headers correctly.\n\nGranted, adhering to the RFC822 to the letter is rather hard. But I have a \nsample program here that can not only parse the escaped double quote, but \nalso take account for the multiple line stuff and multiple headers of the \nsame type where email addresse are valid (To:, Cc:, Bcc:). See attachment. \nFeel free to use the code.\n\n----\n\nfg@erwin ~ $ cat t.txt\nTo: John Doe <some.address@some.tld>, Random Joe <random.joe@abc.def>, \nSuperman <batman@nyc.us>, \"Someone with a comma, inside its tag name\" \n<a@b.com>\nTo: bbr@one2team.com,\n u1@whatever.org,\n  u2@wherever.ru,\n   u3@blah.com\nfg@erwin ~ $ perl t.pl <t.txt\nFound mail: John Doe <some.address@some.tld>\nFound mail: Random Joe <random.joe@abc.def>\nFound mail: Superman <batman@nyc.us>\nFound mail: \"Someone with a comma, inside its tag name\" <a@b.com>\nFound mail: bbr@one2team.com\nFound mail: u1@whatever.org\nFound mail: u2@wherever.ru\nFound mail: u3@blah.com\n----\n\n\n-- \nfge\n"},{"id":"94625","messageId":"20081102043120.GD5261@coredump.intra.peff.net","threadId":"16108","inReplyTo":"1225450632-7230-2-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 1/3] git send-email: avoid leaking directory file descriptors.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-11-02T04:31:20Z","receivedAt":"2008-11-02T04:31:20Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 31, 2008 at 11:57:10AM +0100, Pierre Habouzit wrote:\n\n> +\t\tclosedir(DH);\n\nUgh. This is a great reason to use a scoped variable (like \"my $dh),\nwhich will close automatically. Once upon a time I think you _had_ to\nuse globs for this, but I think it has not been the case for some time\n(and I think we only support back to perl 5.6 these days). Can any perl\ngurus comment?\n\n-Peff\n"},{"id":"94626","messageId":"20081102043523.GE5261@coredump.intra.peff.net","threadId":"16108","inReplyTo":"1225471925-2750-1-git-send-email-madcoder@debian.org","subject":"Re: [PATCH] git send-email: allow any rev-list option as an argument.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-11-02T04:35:23Z","receivedAt":"2008-11-02T04:35:23Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 31, 2008 at 05:52:05PM +0100, Pierre Habouzit wrote:\n\n> Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n> ---\n> \n>   One can consider to squash that on top of\n>   <1225450632-7230-3-git-send-email-madcoder@debian.org> to be able to pass\n>   all non path arguments before a possible '--' to git format-patch.\n\nPersonally, I think the other patch is not useful without this. I often\npull out funny subsets of patches if I know it is safe to do so (e.g., I\ncollect small, unrelated bugfixes directly onto a single branch, but I\nsend them separately).\n\nWith this patch, I might even find send-email usable. :)\n\n-Peff\n"},{"id":"94633","messageId":"7vwsfm3b33.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"1225456609-694-2-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 1/3] git send-email: make the message file name more specific.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-02T06:18:08Z","receivedAt":"2008-11-02T06:18:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> This helps editors choosing their syntax hilighting properly.\n\nEven though I agree this is the right direction to go, unfortunately this\ncan break people's existing setup.\n\nHaving said that, if we were to do this, let's do it the right way and put\nthese \"temporary\" files under $GIT_DIR.\n\n>\n> Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n> ---\n>  git-send-email.perl |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index 65c254d..4ca571f 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -127,7 +127,7 @@ sub unique_email_list(@);\n>  sub cleanup_compose_files();\n>  \n>  # Constants (essentially)\n> -my $compose_filename = \".msg.$$\";\n> +my $compose_filename = \".gitsendemail.msg.$$\";\n>  \n>  # Variables we fill in automatically, or via prompting:\n>  my (@to,@cc,@initial_cc,@bcclist,@xh,\n> -- \n> 1.6.0.3.763.g0275.dirty\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"94634","messageId":"7vskqa3atg.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"1225450632-7230-4-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 3/3] git send-email: add --annotate option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-02T06:23:55Z","receivedAt":"2008-11-02T06:23:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> This allows to review every patch (and fix various aspects of them, or\n> comment them) in an editor just before being sent. Combined to the fact\n> that git send-email can now process revision lists, this makes git\n> send-email and efficient way to review and send patches interactively.\n\nWithout your patches, you run format-patch (with or without cover), you\nuse the editor of your choice to massage them and feed the resulting files\nto send-email.\n\nOnly because you wanted to allow format-patch parameters to be given to\nsend-email, you now need to also allow the messages to be massaged before\nthey are sent out.\n\nIs it only me who finds that this series creates its own problem and then\nhas to solve it?  What are we getting in return?\n"},{"id":"94648","messageId":"20081102093533.GE4066@artemis","threadId":"16108","inReplyTo":"7vwsfm3b33.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 1/3] git send-email: make the message file name more specific.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-02T09:35:33Z","receivedAt":"2008-11-02T09:35:33Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 02, 2008 at 06:18:08AM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > This helps editors choosing their syntax hilighting properly.\n> \n> Even though I agree this is the right direction to go, unfortunately this\n> can break people's existing setup.\n\nWell for now vim (I don't know if emacs has syntax highlight for it)\ndoes:\n    autocmd BufNewFile,BufRead .msg.[0-9]*\n\t  \\ if getline(1) =~ '^From.*# This line is ignored.$' |\n\t  \\   setf gitsendemail |\n\t  \\ endif\n\nEven if you're illiterate in vim script language, you should grok what\nit does, because of the fact that .msg.nnnn is hardly something one can\nrecognize. I believe it's highly unlikely to break anything.\n\nWhat do other people think ?\n\n> Having said that, if we were to do this, let's do it the right way and put\n> these \"temporary\" files under $GIT_DIR.\n\nAgreed, I should have done that.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94650","messageId":"20081102093907.GF4066@artemis","threadId":"16108","inReplyTo":"20081102043523.GE5261@coredump.intra.peff.net","subject":"Re: [PATCH] git send-email: allow any rev-list option as an argument.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-02T09:39:07Z","receivedAt":"2008-11-02T09:39:07Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 02, 2008 at 04:35:23AM +0000, Jeff King wrote:\n> On Fri, Oct 31, 2008 at 05:52:05PM +0100, Pierre Habouzit wrote:\n> \n> > Signed-off-by: Pierre Habouzit <madcoder@debian.org>\n> > ---\n> > \n> >   One can consider to squash that on top of\n> >   <1225450632-7230-3-git-send-email-madcoder@debian.org> to be able to pass\n> >   all non path arguments before a possible '--' to git format-patch.\n> \n> Personally, I think the other patch is not useful without this. I often\n> pull out funny subsets of patches if I know it is safe to do so (e.g., I\n> collect small, unrelated bugfixes directly onto a single branch, but I\n> send them separately).\n> \n> With this patch, I might even find send-email usable. :)\n\nWell it still messes the file/reference name conflict with no way to\nprevent it because of the backward compatibility, and even if unlikely\nit's still possible.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94652","messageId":"20081102095152.GG4066@artemis","threadId":"16108","inReplyTo":"7vskqa3atg.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/3] git send-email: add --annotate option","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-02T09:51:52Z","receivedAt":"2008-11-02T09:51:52Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 02, 2008 at 06:23:55AM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > This allows to review every patch (and fix various aspects of them, or\n> > comment them) in an editor just before being sent. Combined to the fact\n> > that git send-email can now process revision lists, this makes git\n> > send-email and efficient way to review and send patches interactively.\n> \n> Without your patches, you run format-patch (with or without cover), you\n> use the editor of your choice to massage them and feed the resulting files\n> to send-email.\n> \n> Only because you wanted to allow format-patch parameters to be given to\n> send-email, you now need to also allow the messages to be massaged before\n> they are sent out.\n> \n> Is it only me who finds that this series creates its own problem and then\n> has to solve it?  What are we getting in return?\n\nActually my problem is that the current workflow is:\n\n    $ git format-patch [rev-list]\n\n    $ vim *.patch\n\n    # massage patches\n\n    $ git send-email [argument list too long to copy] --compose *.patch\n\n    # struggle in vim to reopen the patches I'm about to comment to copy\n    # the Subject lines and other similar stuff\n\n    # answer to a lot of silly questions that git-s-e should guess from\n    # the cover.\n\n*also* I often have other patches in my repository, and this send-email\nsometimes globs _too many_ patches and this is a big problem for me.\nBasically that and all the '#' bits, and the number of commands to type\nare what make me dislike git-send-email (but still use it since there\nare no good alternatives yet that automate the task).\n\nWith my patch series, the workflow is as follows:\n\n    $ git send-email --to <where> --annotate [rev-list]\n\n    # as vim can open many files at once, I have the cover opened _and_\n    # all the patches at once, or only the patch if there's one single\n    # patch I can massage everything I want.\n\n    # answer 'y' to the _single_ question git-s-e asks.\n    # or 'n' if something doesn't fly.\n\nNot only the command line is considerably shorter (even the --to can be\nomited actually, but unlike --in-reply-to, it rarely changes and it's in\nthe history so...), but more importantly I can see what I will send, no\nmore '*.patch' that will bite me hard. I don't have to struggle opening\nall the patches I'm interested in reading while I comment them in the\ncover, and so on.\n\n\nI mean you're mistaken when you say:\n  ] Only because you wanted to allow format-patch parameters to be\n  ] given to send-email, you now need to also allow the messages to be\n  ] massaged before they are sent out.\n\nYour causality is backwards. I _DO_ want git-send-email to allow me to\ndo the cover _and_ the massaging at once. It's actually the first patch\nI wrote locally even if I reordered the series before sending for some\nreason I don't remember. *Then* if you do that, there's little point in\nhaving to perform git-format-patch in the first place, hence I wanted\nthe feature to let git-format-patch be run by git-send-email directly.\n\nI don't know for others, but with those series, git-send-email is\n_REALLY_ what I would have wanted it to be from day 1. The sole little\nissues I can see are:\n * the To:/Cc:/Bcc:/other headers parsing directly from the cover, for\n   that someone better skilled than me shall add a last patch to do that\n   properly.\n\n * when you only edit one single patch, it doesn't do the From/To/Cc/...\n   parsing and you'll get all the silly interactive questions again.\n   That should probably addressed, but to be frank I care about this one\n   less, because I send single patches directly from mutt. So it's not\n   really my itch to scratch[0] ;)\n\n\n  [0] WHO SAID I'M LAZY ? Yeah you in the back, I HEAR YA!\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94674","messageId":"20081102180220.GA5726@sigio.intra.peff.net","threadId":"16108","inReplyTo":"20081102093907.GF4066@artemis","subject":"Re: [PATCH] git send-email: allow any rev-list option as an argument.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-11-02T18:02:21Z","receivedAt":"2008-11-02T18:02:21Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 02, 2008 at 10:39:07AM +0100, Pierre Habouzit wrote:\n\n> Well it still messes the file/reference name conflict with no way to\n> prevent it because of the backward compatibility, and even if unlikely\n> it's still possible.\n\nHmm. As Junio mentioned, this is really an easier way of doing:\n\n  git format-patch -o tmp \"$@\"\n  $EDITOR tmp/*\n  git send-email tmp\n\nSo I guess a wrapper program would suffice, that just called send-email.\nBut of course then you would have to think of a new name, and explain\nthe confusion between it and send-email.\n\n-Peff\n"},{"id":"94691","messageId":"alpine.LFD.2.00.0811021629110.25369@sys-0.hiltweb.site","threadId":"16108","inReplyTo":"20081102093533.GE4066@artemis","subject":"Re: [PATCH 1/3] git send-email: make the message file name more specific.","fromName":"Ian Hilt","fromEmail":"ian.hilt@gmx.com","sentAt":"2008-11-02T21:34:53Z","receivedAt":"2008-11-02T21:34:53Z","isPatch":true,"sender":{"key":"ian.hilt@gmx.com","avatar":null},"body":"On Sun, 2 Nov 2008, Pierre Habouzit wrote:\n> On Sun, Nov 02, 2008 at 06:18:08AM +0000, Junio C Hamano wrote:\n> > Having said that, if we were to do this, let's do it the right way and put\n> > these \"temporary\" files under $GIT_DIR.\n> \n> Agreed, I should have done that.\n\nPerhaps like this:\n\n\tmy $compose_filename = $repo->repo_path() . \"/sendemail.msg.$$\";\n\nwhere $repo is a repository instance.\n\n\n\tIan\n"},{"id":"94730","messageId":"20081103085337.GB13930@artemis.corp","threadId":"16108","inReplyTo":"alpine.LFD.2.00.0811021629110.25369@sys-0.hiltweb.site","subject":"Re: [PATCH 1/3] git send-email: make the message file name more specific.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-03T08:53:37Z","receivedAt":"2008-11-03T08:53:37Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 02, 2008 at 09:34:53PM +0000, Ian Hilt wrote:\n> On Sun, 2 Nov 2008, Pierre Habouzit wrote:\n> > On Sun, Nov 02, 2008 at 06:18:08AM +0000, Junio C Hamano wrote:\n> > > Having said that, if we were to do this, let's do it the right way and put\n> > > these \"temporary\" files under $GIT_DIR.\n> > \n> > Agreed, I should have done that.\n> \n> Perhaps like this:\n> \n> \tmy $compose_filename = $repo->repo_path() . \"/sendemail.msg.$$\";\n> \n> where $repo is a repository instance.\n\n$repo is a repository instance, I'm waiting for all the comments to fade\nup to take them into account and resend a proper series.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94732","messageId":"20081103091513.GC13930@artemis.corp","threadId":"16108","inReplyTo":"20081102180220.GA5726@sigio.intra.peff.net","subject":"Re: [PATCH] git send-email: allow any rev-list option as an argument.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-03T09:15:13Z","receivedAt":"2008-11-03T09:15:13Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sun, Nov 02, 2008 at 06:02:21PM +0000, Jeff King wrote:\n> On Sun, Nov 02, 2008 at 10:39:07AM +0100, Pierre Habouzit wrote:\n> \n> > Well it still messes the file/reference name conflict with no way to\n> > prevent it because of the backward compatibility, and even if unlikely\n> > it's still possible.\n> \n> Hmm. As Junio mentioned, this is really an easier way of doing:\n> \n>   git format-patch -o tmp \"$@\"\n>   $EDITOR tmp/*\n>   git send-email tmp\n> \n> So I guess a wrapper program would suffice, that just called send-email.\n> But of course then you would have to think of a new name, and explain\n> the confusion between it and send-email.\n\nWell that defeats the purpose of fixing send-email to me. I really would\nlike to see this fixed properly like it should. I mean it makes sense to\nme to use _three_ commands where one should be enough. Not to mention\nthat introducing a new command is just completely against the spirit of\n*simplifying* the current UI ;)\n\nActually I see a few possibilities.\n\n(1) The first one is to pass a --[no]-format-patch flag to\n    git-send-email which says that it should understand arguments as\n    format-patch arguments.  You add to that a sendemail.format-patch\n    setting that would default to false for backward compatibility sake,\n    that would allow the user to force --format-patch as a default.\n\n    This would e.g. cleanly allow:  git send-email --format-patch -3 HEAD.\n\n    I would understand if people dislike the setting: it basically\n    modifies the behaviour of a git command a lot, which has been\n    frowned upon in the past. Even though I would argue than using\n    git-send-email in scripting is quite bad, for something that you can\n    probably replace with:\n\n    while read patchname; do mail some@where.org < $patchname; done < git format-patch \"$@\"\n\n    But if people think it's too dangerous, replacing it with a short\n    switch so that it's not too painful to use would fly for me,\n    something like -F or whatever.\n\n\n(2) Another way is to add a --pass-to-format-patch kind of option that\n    would take its arguments and pass it to git-format-patch. Like in:\n    git send-email --pass-to-format-patch \"-3 HEAD\". (Of course a short\n    switch would help ;p).\n\n(3) Use -- for mandatory separating <format-patch> arguments like this:\n\n\tgit send-email [send-email options] -- -3 HEAD\n\n    or if you want to send patches that would modify only a given path:\n\n        git send-email [s-e options] -- origin/next.. -- git-gui\n\n    that would run internally:\n\n        git format-patch origin/next.. -- git-gui\n\n\nI would say that I dislike (2) a LOT because it's a pain to use: needs a\nlot of quoting, and it gets worse if you want to pass things with spaces\nin it to format-patch.\n\n(2) has the small drawback of not being 100% backward compatible: with\nthe current use of perl Getoptions, -- is used to stop options\nprocessing, and people _may_ have used it to do `git s-e -- --my.patch`\nand such a use would break. However this is highly unlikely to cause\nissues in real life I think (unlike the problem of refs against filename\nclashes).\n\nIn (1) people may dislike the idea of a setting, I've not strong\nfeelings about it, I won't mind if it gets rejected, a short switch will\ndo just fine then.\n\n\nAs a summary, I'd say that I like both (1) and (3) because those are\nhandy, short, and either completely or mostly backward compatible. My\nway would be to go down (1) and add a alias.s-e = !git send-email -F in\nmy .gitconfig.\n\nWhat do you think ?\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94752","messageId":"vpqk5blknok.fsf@bauges.imag.fr","threadId":"16108","inReplyTo":"20081102095152.GG4066@artemis","subject":"Re: [PATCH 3/3] git send-email: add --annotate option","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2008-11-03T12:18:35Z","receivedAt":"2008-11-03T12:18:35Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> I don't know for others, but with those series, git-send-email is\n> _REALLY_ what I would have wanted it to be from day 1.\n\nSame for me. I didn't really understand why git was asking me to run\ntwo separate commands to send a patch. Having git-send-email do\neverything and ask me only the required is really the way I expected\nit to be.\n\n(probably not a coincidence that at least bzr and darcs have a \"send\"\ncommand that does just this)\n\n-- \nMatthieu\n"},{"id":"94834","messageId":"7vej1sti78.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"20081103091513.GC13930@artemis.corp","subject":"Re: [PATCH] git send-email: allow any rev-list option as an argument.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-04T01:04:27Z","receivedAt":"2008-11-04T01:04:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> As a summary, I'd say that I like both (1) and (3) because those are\n> handy, short, and either completely or mostly backward compatible. My\n> way would be to go down (1) and add a alias.s-e = !git send-email -F in\n> my .gitconfig.\n>\n> What do you think ?\n\nI wonder if we can do this even without an explicit -F.\n\nWhat command line arguments does send-email take, and what options would\nwe want to give the underlying format-patch?  Can't you sift them without\nambiguity?\n\nThe current syntax is:\n\n    git send-email <flags>... <file|dir>...\n\nI am wondering if we can just extend it to:\n\n    git send-email <flags>... <<file|dir>...|rev>\n\nE.g. we should be able to parse this out:\n\n    git send-email --to git@vger.kernel.org -M --suppress-cc=all origin\n\nand notice \"--to git@vger.kernel.org\" and \"--suppress-cc\" are for\nsend-email, guess \"-M\" (or anything that is outside the current\nsend-email's vocabulary) is meant for format-patch, and if there is no\nfile or directory called \"origin\" then decide that the user wants to run\nformat-patch, and act as a front-end as if the user did:\n\n\tgit format-patch -o tmp.$$ -M origin &&\n        ... perhaps do your --annotate and --compose here by launching\n        ... the editor...\n        git send-email --to git@vger.kernel.org --suppress-cc=all tmp.$$ &&\n\trm -fr tmp.$$\n\nIf you happen to have a file or a directory called origin, it would be\nsafer for users if the command errored out asking for disambiguation.  The\nuser can either say \"./origin\" or \"origin^0\" to disambiguate between them.\n\nHmm?\n"},{"id":"94868","messageId":"20081104081931.GA3788@artemis.corp","threadId":"16108","inReplyTo":"7vej1sti78.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git send-email: allow any rev-list option as an argument.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-04T08:19:31Z","receivedAt":"2008-11-04T08:19:31Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Tue, Nov 04, 2008 at 01:04:27AM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > As a summary, I'd say that I like both (1) and (3) because those are\n> > handy, short, and either completely or mostly backward compatible. My\n> > way would be to go down (1) and add a alias.s-e = !git send-email -F in\n> > my .gitconfig.\n> >\n> > What do you think ?\n> \n> I wonder if we can do this even without an explicit -F.\n> \n> What command line arguments does send-email take, and what options would\n> we want to give the underlying format-patch?  Can't you sift them without\n> ambiguity?\n> \n> The current syntax is:\n> \n>     git send-email <flags>... <file|dir>...\n> \n> I am wondering if we can just extend it to:\n> \n>     git send-email <flags>... <<file|dir>...|rev>\n> \n> E.g. we should be able to parse this out:\n> \n>     git send-email --to git@vger.kernel.org -M --suppress-cc=all origin\n> \n> and notice \"--to git@vger.kernel.org\" and \"--suppress-cc\" are for\n> send-email, guess \"-M\" (or anything that is outside the current\n> send-email's vocabulary) is meant for format-patch, and if there is no\n> file or directory called \"origin\" then decide that the user wants to run\n> format-patch, and act as a front-end as if the user did:\n> \n> \tgit format-patch -o tmp.$$ -M origin &&\n>         ... perhaps do your --annotate and --compose here by launching\n>         ... the editor...\n>         git send-email --to git@vger.kernel.org --suppress-cc=all tmp.$$ &&\n> \trm -fr tmp.$$\n> \n> If you happen to have a file or a directory called origin, it would be\n> safer for users if the command errored out asking for disambiguation.  The\n> user can either say \"./origin\" or \"origin^0\" to disambiguate between them.\n\nOh right you can disambiguate references using ^0 so maybe my proposal\nworks after all, though it has to check for each file name if it's not a\nreference _also_. I like it. I will rework my patch series now then,\nsince most of the discussed points of them have been addressed in the\nthread.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94899","messageId":"1225815858-30617-1-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225450632-7230-1-git-send-email-madcoder@debian.org","subject":"[take 2] git send-email updates","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-04T16:24:13Z","receivedAt":"2008-11-04T16:24:13Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"  [PATCH 1/5] git send-email: make the message file name more specific.\n    self described\n\n  [PATCH 2/5] git send-email: interpret unknown files as revision lists\n    All unknown arguments are passed to git-format-patch at once,\n    checking for possible file/rev conflicts and dying in that case,\n    like Junio suggested.\n\n  [PATCH 3/5] git send-email: add --annotate option\n    same as before.\n\n  [PATCH 4/5] git send-email: ask less questions when --compose is used.\n    same as before, with an update wrt empty bodies. Still doesn't grok\n    To/Cc/Bcc. I would be really glad if a patch to deal with it was\n    appended to that series, but a patch that deals with Header\n    continuations well.\n\n  [PATCH 5/5] git send-email: turn --compose on when more than one patch.\n    This patch is probably controversial. I propose it not because I'm\n    lazy, I now have a 'git send' alias for the task that expands to\n    'send-email -C -C -M -n --annotate --compose --to'. I propose it\n    because I believe it's a good thing to make people write about their\n    stuff when there is a series and not a single patch. If they still\n    don't want to, they just have to clear the mail buffer at once.\n\n    The drawback is that it _may_ break some scripts, those people would\n    have to pass --no-compose to their send-email call to fix the\n    scripts.\n\n    I wouldn't complain if the patch gets dropped.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94900","messageId":"1225815858-30617-2-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225815858-30617-1-git-send-email-madcoder@debian.org","subject":"[PATCH 1/5] git send-email: make the message file name more specific.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-04T16:24:14Z","receivedAt":"2008-11-04T16:24:14Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"This helps editors choosing their syntax hilighting properly.\n\nAlso make the file live under the git directory.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-send-email.perl |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 94ca5c8..aaace02 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -124,9 +124,6 @@ my $auth;\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_cc,@bcclist,@xh,\n \t$initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);\n@@ -149,6 +146,7 @@ if ($@) {\n \n # Behavior modification variables\n my ($quiet, $dry_run) = (0, 0);\n+my $compose_filename = $repo->repo_path() . \"/.gitsendemail.msg.$$\";\n \n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);\n-- \n1.5.6.5\n"},{"id":"94904","messageId":"1225815858-30617-3-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225815858-30617-2-git-send-email-madcoder@debian.org","subject":"[PATCH 2/5] git send-email: interpret unknown files as revision lists","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-04T16:24:15Z","receivedAt":"2008-11-04T16:24:15Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Filter out all the arguments git-send-email doesn't like to a\ngit format-patch command, that dumps its content to a safe directory.\n\nBarf when a file/revision conflict occurs.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-send-email.txt |    2 +-\n git-send-email.perl              |   28 ++++++++++++++++++++++++----\n 2 files changed, 25 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 82f5056..4654d4f 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -8,7 +8,7 @@ git-send-email - Send a collection of patches as emails\n \n SYNOPSIS\n --------\n-'git send-email' [options] <file|directory> [... file|directory]\n+'git send-email' [options] <file|directory|rev-list options>...\n \n \n DESCRIPTION\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex aaace02..c29868a 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -22,8 +22,11 @@ use Term::ReadLine;\n use Getopt::Long;\n use Data::Dumper;\n use Term::ANSIColor;\n+use File::Temp qw/ tempdir /;\n use Git;\n \n+Getopt::Long::Configure qw/ pass_through /;\n+\n package FakeTerm;\n sub new {\n \tmy ($class, $reason) = @_;\n@@ -38,7 +41,7 @@ package main;\n \n sub usage {\n \tprint <<EOT;\n-git send-email [options] <file | directory>...\n+git send-email [options] <file | directory | rev-list options >\n \n   Composing:\n     --from                  <str>  * Email From:\n@@ -363,10 +366,22 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\n \n ($sender) = expand_aliases($sender) if defined $sender;\n \n+sub check_file_rev_conflict($) {\n+\tmy $f = shift;\n+\tif ($repo->command('rev-parse', '--verify', '--quiet', $f)) {\n+\t\tdie(\"revision/filename conflict on `$f'\");\n+\t}\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-\tif (-d $f) {\n+my @rev_list_opts;\n+while (my $f = pop @ARGV) {\n+\tif ($f eq \"--\") {\n+\t\tpush @rev_list_opts, \"--\", @ARGV;\n+\t\t@ARGV = ();\n+\t} elsif (-d $f) {\n+\t\tcheck_file_rev_conflict($f);\n \t\topendir(DH,$f)\n \t\t\tor die \"Failed to opendir $f: $!\";\n \n@@ -374,12 +389,17 @@ for my $f (@ARGV) {\n \t\t\t\tsort readdir(DH);\n \t\tclosedir(DH);\n \t} elsif (-f $f or -p $f) {\n+\t\tcheck_file_rev_conflict($f);\n \t\tpush @files, $f;\n \t} else {\n-\t\tprint STDERR \"Skipping $f - not found.\\n\";\n+\t\tpush @rev_list_opts, $f;\n \t}\n }\n \n+if (@rev_list_opts) {\n+\tpush @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);\n+}\n+\n if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\n-- \n1.5.6.5\n"},{"id":"94902","messageId":"1225815858-30617-4-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225815858-30617-3-git-send-email-madcoder@debian.org","subject":"[PATCH 3/5] git send-email: add --annotate option","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-04T16:24:16Z","receivedAt":"2008-11-04T16:24:16Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"This allows to review every patch (and fix various aspects of them, or\ncomment them) in an editor just before being sent. Combined to the fact\nthat git send-email can now process revision lists, this makes git\nsend-email and efficient way to review and send patches interactively.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-send-email.txt |   11 +++++++++++\n git-send-email.perl              |   26 ++++++++++++++++++++++++--\n 2 files changed, 35 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 4654d4f..39d6da9 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -37,6 +37,11 @@ The --bcc option must be repeated for each user you want on the bcc list.\n +\n The --cc option must be repeated for each user you want on the cc list.\n \n+--annotate::\n+\tReview each patch you're about to send in an editor. The setting\n+\t'sendemail.multiedit' defines if this will spawn one editor per patch\n+\tor one for all of them at once.\n+\n --compose::\n \tUse $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an\n \tintroductory message for the patch series.\n@@ -204,6 +209,12 @@ sendemail.aliasfiletype::\n \tFormat of the file(s) specified in sendemail.aliasesfile. Must be\n \tone of 'mutt', 'mailrc', 'pine', or 'gnus'.\n \n+sendemail.multiedit::\n+\tIf true (default), a single editor instance will be spawned to edit\n+\tfiles you have to edit (patches when '--annotate' is used, and the\n+\tsummary when '--compose' is used). If false, files will be edited one\n+\tafter the other, spawning a new editor each time.\n+\n \n Author\n ------\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex c29868a..d0c5a41 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -50,6 +50,7 @@ git send-email [options] <file | directory | rev-list options >\n     --bcc                   <str>  * Email Bcc:\n     --subject               <str>  * Email \"Subject:\"\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n+    --annotate                     * Review each patch that will be sent in an editor.\n     --compose                      * Open an editor for introduction.\n \n   Sending:\n@@ -129,7 +130,8 @@ sub cleanup_compose_files();\n \n # Variables we fill in automatically, or via prompting:\n my (@to,@cc,@initial_cc,@bcclist,@xh,\n-\t$initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);\n+\t$initial_reply_to,$initial_subject,@files,\n+\t$author,$sender,$smtp_authpass,$annotate,$compose,$time);\n \n my $envelope_sender;\n \n@@ -151,6 +153,17 @@ if ($@) {\n my ($quiet, $dry_run) = (0, 0);\n my $compose_filename = $repo->repo_path() . \"/.gitsendemail.msg.$$\";\n \n+# Handle interactive edition of files.\n+my $multiedit;\n+my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n+sub do_edit {\n+\tif (defined($multiedit) && !$multiedit) {\n+\t\tmap { system('sh', '-c', $editor.' \"$@\"', $editor, $_); } @_;\n+\t} else {\n+\t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, @_);\n+\t}\n+}\n+\n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);\n my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);\n@@ -180,6 +193,7 @@ my %config_settings = (\n     \"aliasesfile\" => \\@alias_files,\n     \"suppresscc\" => \\@suppress_cc,\n     \"envelopesender\" => \\$envelope_sender,\n+    \"multiedit\" => \\$multiedit,\n );\n \n # Handle Uncouth Termination\n@@ -222,6 +236,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"smtp-ssl\" => sub { $smtp_encryption = 'ssl' },\n \t\t    \"smtp-encryption=s\" => \\$smtp_encryption,\n \t\t    \"identity=s\" => \\$identity,\n+\t\t    \"annotate\" => \\$annotate,\n \t\t    \"compose\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n@@ -515,7 +530,12 @@ EOT\n \tclose(C);\n \n \tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n-\tsystem('sh', '-c', $editor.' \"$@\"', $editor, $compose_filename);\n+\n+\tif ($annotate) {\n+\t\tdo_edit($compose_filename, @files);\n+\t} else {\n+\t\tdo_edit($compose_filename);\n+\t}\n \n \topen(C2,\">\",$compose_filename . \".final\")\n \t\tor die \"Failed to open $compose_filename.final : \" . $!;\n@@ -564,6 +584,8 @@ EOT\n \t}\n \n \t@files = ($compose_filename . \".final\", @files);\n+} elsif ($annotate) {\n+\tdo_edit(@files);\n }\n \n # Variables we set as part of the loop over files\n-- \n1.5.6.5\n"},{"id":"94903","messageId":"1225815858-30617-5-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225815858-30617-4-git-send-email-madcoder@debian.org","subject":"[PATCH 4/5] git send-email: ask less questions when --compose is used.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-04T16:24:17Z","receivedAt":"2008-11-04T16:24:17Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"When --compose is used, we can grab the From/Subject/In-Reply-To from the\nedited summary, let it be so and don't ask the user silly questions.\n\nThe summary templates gets quite revamped, and includes the list of\npatches subjects that are going to be sent with this batch.\n\nWhen having a body full of empty lines, the summary isn't sent. Document\nthat in the git-send-email manpage fully.\n\nNote: It doesn't deal with To/Cc/Bcc yet.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-send-email.txt |    9 ++\n git-send-email.perl              |  177 ++++++++++++++++++++++---------------\n 2 files changed, 114 insertions(+), 72 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 39d6da9..e06db6b 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -45,6 +45,15 @@ The --cc option must be repeated for each user you want on the cc list.\n --compose::\n \tUse $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an\n \tintroductory message for the patch series.\n++\n+When compose is in used, git send-email gets less interactive will use the\n+values of the headers you set there. If the body of the email (what you type\n+after the headers and a blank line) only contains blank (or GIT: prefixed)\n+lines, the summary won't be sent, but git-send-email will still use the\n+Headers values if you don't removed them.\n++\n+If it wasn't able to see a header in the summary it will ask you about it\n+interactively after quitting your editor.\n \n --from::\n \tSpecify the sender of the emails.  This will default to\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex d0c5a41..fd72127 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -433,6 +433,108 @@ if (@files) {\n \tusage();\n }\n \n+sub get_patch_subject($) {\n+\tmy $fn = shift;\n+\topen (my $fh, '<', $fn);\n+\twhile (my $line = <$fh>) {\n+\t\tnext unless ($line =~ /^Subject: (.*)$/);\n+\t\tclose $fh;\n+\t\treturn \"GIT: $1\\n\";\n+\t}\n+\tclose $fh;\n+\tdie \"No subject line in $fn ?\";\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+\n+\n+\tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n+\tmy $tpl_subject = $initial_subject || '';\n+\tmy $tpl_reply_to = $initial_reply_to || '';\n+\n+\tprint C <<EOT;\n+From $tpl_sender # This line is ignored.\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+GIT:\n+GIT: Clear the body content if you don't wish to send a summary.\n+From: $tpl_sender\n+Subject: $tpl_subject\n+In-Reply-To: $tpl_reply_to\n+\n+EOT\n+\tfor my $f (@files) {\n+\t\tprint C get_patch_subject($f);\n+\t}\n+\tclose(C);\n+\n+\tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n+\n+\tif ($annotate) {\n+\t\tdo_edit($compose_filename, @files);\n+\t} else {\n+\t\tdo_edit($compose_filename);\n+\t}\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+\tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n+\tmy $in_body = 0;\n+\tmy $summary_empty = 1;\n+\twhile(<C>) {\n+\t\tnext if m/^GIT: /;\n+\t\tif ($in_body) {\n+\t\t\t$summary_empty = 0 unless (/^\\n$/);\n+\t\t} elsif (/^\\n$/) {\n+\t\t\t$in_body = 1;\n+\t\t\tif ($need_8bit_cte) {\n+\t\t\t\tprint C2 \"MIME-Version: 1.0\\n\",\n+\t\t\t\t\t \"Content-Type: text/plain; \",\n+\t\t\t\t\t   \"charset=utf-8\\n\",\n+\t\t\t\t\t \"Content-Transfer-Encoding: 8bit\\n\";\n+\t\t\t}\n+\t\t} elsif (/^MIME-Version:/i) {\n+\t\t\t$need_8bit_cte = 0;\n+\t\t} elsif (/^Subject:\\s*(.+)\\s*$/i) {\n+\t\t\t$initial_subject = $1;\n+\t\t\tmy $subject = $initial_subject;\n+\t\t\t$_ = \"Subject: \" .\n+\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n+\t\t\t\t quote_rfc2047($subject) :\n+\t\t\t\t $subject) .\n+\t\t\t\t\"\\n\";\n+\t\t} elsif (/^In-Reply-To:\\s*(.+)\\s*$/i) {\n+\t\t\t$initial_reply_to = $1;\n+\t\t\tnext;\n+\t\t} elsif (/^From:\\s*(.+)\\s*$/i) {\n+\t\t\t$sender = $1;\n+\t\t\tnext;\n+\t\t} elsif (/^(?:To|Cc|Bcc):/i) {\n+\t\t\tprint \"To/Cc/Bcc fields are not interpreted yet, they have been ignored\\n\";\n+\t\t\tnext;\n+\t\t}\n+\t\tprint C2 $_;\n+\t}\n+\tclose(C);\n+\tclose(C2);\n+\n+\tif ($summary_empty) {\n+\t\tprint \"Summary email is empty, skpping it\\n\";\n+\t\t$compose = -1;\n+\t}\n+} elsif ($annotate) {\n+\tdo_edit(@files);\n+}\n+\n my $prompting = 0;\n if (!defined $sender) {\n \t$sender = $repoauthor || $repocommitter || '';\n@@ -477,17 +579,6 @@ sub expand_aliases {\n @initial_cc = expand_aliases(@initial_cc);\n @bcclist = expand_aliases(@bcclist);\n \n-if (!defined $initial_subject && $compose) {\n-\twhile (1) {\n-\t\t$_ = $term->readline(\"What subject should the initial email start with? \", $initial_subject);\n-\t\tlast if defined $_;\n-\t\tprint \"\\n\";\n-\t}\n-\n-\t$initial_subject = $_;\n-\t$prompting++;\n-}\n-\n if ($thread && !defined $initial_reply_to && $prompting) {\n \twhile (1) {\n \t\t$_= $term->readline(\"Message-ID to be used as In-Reply-To for the first email? \", $initial_reply_to);\n@@ -514,64 +605,6 @@ if (!defined $smtp_server) {\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 $sender # This line is ignored.\\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{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n-\n-\tif ($annotate) {\n-\t\tdo_edit($compose_filename, @files);\n-\t} else {\n-\t\tdo_edit($compose_filename);\n-\t}\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-\tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n-\tmy $in_body = 0;\n-\twhile(<C>) {\n-\t\tnext if m/^GIT: /;\n-\t\tif (!$in_body && /^\\n$/) {\n-\t\t\t$in_body = 1;\n-\t\t\tif ($need_8bit_cte) {\n-\t\t\t\tprint C2 \"MIME-Version: 1.0\\n\",\n-\t\t\t\t\t \"Content-Type: text/plain; \",\n-\t\t\t\t\t   \"charset=utf-8\\n\",\n-\t\t\t\t\t \"Content-Transfer-Encoding: 8bit\\n\";\n-\t\t\t}\n-\t\t}\n-\t\tif (!$in_body && /^MIME-Version:/i) {\n-\t\t\t$need_8bit_cte = 0;\n-\t\t}\n-\t\tif (!$in_body && /^Subject: ?(.*)/i) {\n-\t\t\tmy $subject = $1;\n-\t\t\t$_ = \"Subject: \" .\n-\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n-\t\t\t\t quote_rfc2047($subject) :\n-\t\t\t\t $subject) .\n-\t\t\t\t\"\\n\";\n-\t\t}\n-\t\tprint C2 $_;\n-\t}\n-\tclose(C);\n-\tclose(C2);\n-\n \twhile (1) {\n \t\t$_ = $term->readline(\"Send this email? (y|n) \");\n \t\tlast if defined $_;\n@@ -583,9 +616,9 @@ EOT\n \t\texit(0);\n \t}\n \n-\t@files = ($compose_filename . \".final\", @files);\n-} elsif ($annotate) {\n-\tdo_edit(@files);\n+\tif ($compose > 0) {\n+\t\t@files = ($compose_filename . \".final\", @files);\n+\t}\n }\n \n # Variables we set as part of the loop over files\n-- \n1.5.6.5\n"},{"id":"94901","messageId":"1225815858-30617-6-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225815858-30617-5-git-send-email-madcoder@debian.org","subject":"[PATCH 5/5] git send-email: turn --compose on when more than one patch.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-04T16:24:18Z","receivedAt":"2008-11-04T16:24:18Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Automatically turn --compose on when there is more than one patch, and\nthat the output is a tty.\n\nDo not print the list of files sent anymore in that case, as the list is\nshown in the summary editor.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-send-email.perl |   10 +++++++---\n 1 files changed, 7 insertions(+), 3 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex fd72127..3c7818f 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -51,7 +51,7 @@ git send-email [options] <file | directory | rev-list options >\n     --subject               <str>  * Email \"Subject:\"\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n     --annotate                     * Review each patch that will be sent in an editor.\n-    --compose                      * Open an editor for introduction.\n+    --[no-]compose                 * Open an editor for introduction.\n \n   Sending:\n     --envelope-sender       <str>  * Email envelope sender.\n@@ -237,7 +237,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"smtp-encryption=s\" => \\$smtp_encryption,\n \t\t    \"identity=s\" => \\$identity,\n \t\t    \"annotate\" => \\$annotate,\n-\t\t    \"compose\" => \\$compose,\n+\t\t    \"compose!\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n \t\t    \"suppress-from!\" => \\$suppress_from,\n@@ -425,7 +425,11 @@ if ($validate) {\n }\n \n if (@files) {\n-\tunless ($quiet) {\n+\tif (!defined($compose) && -t STDOUT) {\n+\t\t# turn $compose on if there is more than one file\n+\t\t$compose = $#files;\n+\t}\n+\tunless ($quiet || $compose) {\n \t\tprint $_,\"\\n\" for (@files);\n \t}\n } else {\n-- \n1.5.6.5\n"},{"id":"94916","messageId":"200811042109.54809.fg@one2team.net","threadId":"16108","inReplyTo":"1225815858-30617-5-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 4/5] git send-email: ask less questions when --compose is used.","fromName":"Francis Galiegue","fromEmail":"fg@one2team.net","sentAt":"2008-11-04T20:09:54Z","receivedAt":"2008-11-04T20:09:54Z","isPatch":true,"sender":{"key":"fg@one2team.net","avatar":null},"body":"Le Tuesday 04 November 2008 17:24:17, vous avez écrit :\n> +       if ($summary_empty) {\n> +               print \"Summary email is empty, --> skpping <-- it\\n\";\n> \n\nTypo...\n\n-- \nfge\n"},{"id":"94936","messageId":"7v1vxroxn1.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"1225815858-30617-3-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 2/5] git send-email: interpret unknown files as revision lists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-04T23:54:26Z","receivedAt":"2008-11-04T23:54:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index aaace02..c29868a 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -22,8 +22,11 @@ use Term::ReadLine;\n>  use Getopt::Long;\n>  use Data::Dumper;\n>  use Term::ANSIColor;\n> +use File::Temp qw/ tempdir /;\n\nWe seem to use File::Temp::tempdir already elsewhere, but they are in\narchimport, cvsexportcommit and cvsserver, all of which are rather rarely\nused ones.  I think this is Perl 5.6.1 addition.  Is everybody Ok with\nthis dependency?  Just double checking.\n\n> @@ -363,10 +366,22 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\n>  \n>  ($sender) = expand_aliases($sender) if defined $sender;\n>  \n> +sub check_file_rev_conflict($) {\n> +\tmy $f = shift;\n> +\tif ($repo->command('rev-parse', '--verify', '--quiet', $f)) {\n> +\t\tdie(\"revision/filename conflict on `$f'\");\n\nPerhaps wording this a bit more to the point?  This is triggered when \n'$f' can be both a filename or a revision, so...\n\n\tFile '$f' exists but it could also be the range of commits\n        to produce patches for.  Please disambiguate by...\n\n\t* Saying \"./$f\" if you mean a file; or\n        * Giving -F option if you mean a range.\n\nEarlier I suggested that \"origin^0\" is a way for the user to disambiguate\nfavouring a rev, but such a filename can exist, so we cannot blindly\nsuggest to say \"$f^0\" here.  I think adding -F (or --format-patch) option\nto send-email to explicitly disable file/directory interpretation would be\na cleaner solution for this (and it would allow you to drive this from a\nscript without worrying about what garbage files you happen to have in the\nworking tree).\n"},{"id":"94939","messageId":"7vvdv3nj28.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"1225815858-30617-5-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 4/5] git send-email: ask less questions when --compose is used.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-04T23:54:39Z","receivedAt":"2008-11-04T23:54:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> +\tprint C <<EOT;\n> +From $tpl_sender # This line is ignored.\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> +GIT:\n> +GIT: Clear the body content if you don't wish to send a summary.\n> +From: $tpl_sender\n> +Subject: $tpl_subject\n> +In-Reply-To: $tpl_reply_to\n> +\n\nSomebody already suggested this but I really think GIT: lines should be at\nthe end and use '# ' prefix instead.\n\nWith the ability to give --cover-letter option to underlying format-patch\ndo you still need this?\n\n> +\tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n> +\n> +\tif ($annotate) {\n> +\t\tdo_edit($compose_filename, @files);\n> +\t} else {\n> +\t\tdo_edit($compose_filename);\n> +\t}\n\nDon't we want to abort the whole process when the user kills the editor\ninstead of normal exit (iow, do_edit() which is system() reports that the\neditor was killed)?\n"},{"id":"94938","messageId":"7vprlbnj1t.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"1225815858-30617-6-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 5/5] git send-email: turn --compose on when more than one patch.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-04T23:54:54Z","receivedAt":"2008-11-04T23:54:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> Automatically turn --compose on when there is more than one patch, and\n> that the output is a tty.\n\nI do not think this is a good idea.  I suspect I am not the only person\nwho uses \"format-patch --cover-letter\", edit the files to review and\nprepare, and runs send-email to fire them off.\n"},{"id":"94955","messageId":"20081105033151.GB24886@coredump.intra.peff.net","threadId":"16108","inReplyTo":"7vprlbnj1t.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 5/5] git send-email: turn --compose on when more than one patch.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-11-05T03:31:51Z","receivedAt":"2008-11-05T03:31:51Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 04, 2008 at 03:54:54PM -0800, Junio C Hamano wrote:\n\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > Automatically turn --compose on when there is more than one patch, and\n> > that the output is a tty.\n> \n> I do not think this is a good idea.  I suspect I am not the only person\n> who uses \"format-patch --cover-letter\", edit the files to review and\n> prepare, and runs send-email to fire them off.\n\nMaybe a config option to turn this behavior on? It seems specific to\ndifferent workflows (i.e., whether or not you are using \"git send-email\n$REVS\" or using format-patch first).\n\n-Peff\n"},{"id":"94963","messageId":"7viqr2mz75.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"20081105033151.GB24886@coredump.intra.peff.net","subject":"Re: [PATCH 5/5] git send-email: turn --compose on when more than one patch.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-05T07:03:42Z","receivedAt":"2008-11-05T07:03:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Nov 04, 2008 at 03:54:54PM -0800, Junio C Hamano wrote:\n>\n>> Pierre Habouzit <madcoder@debian.org> writes:\n>> \n>> > Automatically turn --compose on when there is more than one patch, and\n>> > that the output is a tty.\n>> \n>> I do not think this is a good idea.  I suspect I am not the only person\n>> who uses \"format-patch --cover-letter\", edit the files to review and\n>> prepare, and runs send-email to fire them off.\n>\n> Maybe a config option to turn this behavior on? It seems specific to\n> different workflows (i.e., whether or not you are using \"git send-email\n> $REVS\" or using format-patch first).\n\nYeah, if send-email did not have --compose to begin with, we could just\nsay \"don't use --compose; use --cover-letter when you use send-email to\nfront-end format-patch instead\", but some people perhaps are used to run\nformat-patch separately without --cover-letter and then create the cover\nletter from scratch with --compose (which seems a bit more work to me,\nthough).\n\nSo I am not opposed to a sendemail.foo configuration option.\n"},{"id":"94968","messageId":"20081105104001.GA22272@artemis.corp","threadId":"16108","inReplyTo":"7viqr2mz75.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/5] git send-email: interpret unknown files as revision lists","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-05T10:40:01Z","receivedAt":"2008-11-05T10:40:01Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Tue, Nov 04, 2008 at 11:54:26PM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n\n> > @@ -363,10 +366,22 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\n> >  \n> >  ($sender) = expand_aliases($sender) if defined $sender;\n> >  \n> > +sub check_file_rev_conflict($) {\n> > +\tmy $f = shift;\n> > +\tif ($repo->command('rev-parse', '--verify', '--quiet', $f)) {\n> > +\t\tdie(\"revision/filename conflict on `$f'\");\n> \n> Perhaps wording this a bit more to the point?  This is triggered when \n> '$f' can be both a filename or a revision, so...\n> \n> \tFile '$f' exists but it could also be the range of commits\n>         to produce patches for.  Please disambiguate by...\n> \n> \t* Saying \"./$f\" if you mean a file; or\n>         * Giving -F option if you mean a range.\n> \n> Earlier I suggested that \"origin^0\" is a way for the user to disambiguate\n> favouring a rev, but such a filename can exist, so we cannot blindly\n> suggest to say \"$f^0\" here.  I think adding -F (or --format-patch) option\n> to send-email to explicitly disable file/directory interpretation would be\n> a cleaner solution for this (and it would allow you to drive this from a\n> script without worrying about what garbage files you happen to have in the\n> working tree).\n\nOkay, still having --[no-]format-patch is probably a good idea indeed\nfor scripts. Will do.\n\nOn Tue, Nov 04, 2008 at 11:54:39PM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > +\tprint C <<EOT;\n> > +From $tpl_sender # This line is ignored.\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> > +GIT:\n> > +GIT: Clear the body content if you don't wish to send a summary.\n> > +From: $tpl_sender\n> > +Subject: $tpl_subject\n> > +In-Reply-To: $tpl_reply_to\n> > +\n> \n> Somebody already suggested this but I really think GIT: lines should be at\n> the end and use '# ' prefix instead.\n\nThis will break previous editor syntax hilighting stuff even more, and\nhas the drawback that you can't put shell sniplets in here. I think it's\nwhy GIT: was chosen. But maybe we just don't care.\n\n> With the ability to give --cover-letter option to underlying format-patch\n> do you still need this?\n> \n> > +\tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n> > +\n> > +\tif ($annotate) {\n> > +\t\tdo_edit($compose_filename, @files);\n> > +\t} else {\n> > +\t\tdo_edit($compose_filename);\n> > +\t}\n> \n> Don't we want to abort the whole process when the user kills the editor\n> instead of normal exit (iow, do_edit() which is system() reports that the\n> editor was killed)?\n\nProbably, I kept what was done as is, but we probably want do_edit() to\ndie() if the user killed it.\n\nOn mer, nov 05, 2008 at 07:03:42 +0000, Junio C Hamano wrote:\n> Jeff King <peff@peff.net> writes:\n> > On Tue, Nov 04, 2008 at 03:54:54PM -0800, Junio C Hamano wrote:\n> Yeah, if send-email did not have --compose to begin with, we could just\n> say \"don't use --compose; use --cover-letter when you use send-email to\n> front-end format-patch instead\", but some people perhaps are used to run\n> format-patch separately without --cover-letter and then create the cover\n> letter from scratch with --compose (which seems a bit more work to me,\n> though).\n> \n> So I am not opposed to a sendemail.foo configuration option.\n\nWill do\n\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94974","messageId":"7vd4hamcbn.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"20081105104001.GA22272@artemis.corp","subject":"Re: [PATCH 2/5] git send-email: interpret unknown files as revision lists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-05T15:17:48Z","receivedAt":"2008-11-05T15:17:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> On Tue, Nov 04, 2008 at 11:54:26PM +0000, Junio C Hamano wrote:\n>\n>> Somebody already suggested this but I really think GIT: lines should be at\n>> the end and use '# ' prefix instead.\n>\n> This will break previous editor syntax hilighting stuff even more, and\n> has the drawback that you can't put shell sniplets in here. I think it's\n> why GIT: was chosen. But maybe we just don't care.\n\nAh, please scratch that \"I really think\" --- my mistake.\n\nI did not check nor realize \"GIT:\" is what send-email already does.\n"},{"id":"95276","messageId":"7vmyg8afu4.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"20081105104001.GA22272@artemis.corp","subject":"Re: [PATCH 2/5] git send-email: interpret unknown files as revision lists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-09T18:56:19Z","receivedAt":"2008-11-09T18:56:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> Okay, still having --[no-]format-patch is probably a good idea indeed\n> for scripts. Will do.\n> ...\n> Probably, I kept what was done as is, but we probably want do_edit() to\n> die() if the user killed it.\n> ...\n>> So I am not opposed to a sendemail.foo configuration option.\n>\n> Will do\n\nThanks.\n"},{"id":"95410","messageId":"1226361242-2516-1-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1225450632-7230-1-git-send-email-madcoder@debian.org","subject":"[take 2] git send-email updates","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-10T23:53:58Z","receivedAt":"2008-11-10T23:53:58Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"The last patch is dropped for now (the automatic --compose stuff)\nbecause I'm not sure which option to add, and that I don't care enough\nabout it to spend more time on it.\n\nI think I've incorporated most of the stuff people asked about in this\nseries.\n\n [PATCH 1/4] git send-email: make the message file name more specific.\n [PATCH 2/4] git send-email: interpret unknown files as revision lists\n [PATCH 3/4] git send-email: add --annotate option\n [PATCH 4/4] git send-email: ask less questions when --compose is used.\n"},{"id":"95412","messageId":"1226361242-2516-2-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1226361242-2516-1-git-send-email-madcoder@debian.org","subject":"[PATCH 1/4] git send-email: make the message file name more specific.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-10T23:53:59Z","receivedAt":"2008-11-10T23:53:59Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"This helps editors choosing their syntax hilighting properly.\n\nAlso make the file live under the git directory.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n git-send-email.perl |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 94ca5c8..aaace02 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -124,9 +124,6 @@ my $auth;\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_cc,@bcclist,@xh,\n \t$initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);\n@@ -149,6 +146,7 @@ if ($@) {\n \n # Behavior modification variables\n my ($quiet, $dry_run) = (0, 0);\n+my $compose_filename = $repo->repo_path() . \"/.gitsendemail.msg.$$\";\n \n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);\n-- \n1.6.0.4.859.g7ecd.dirty\n"},{"id":"95414","messageId":"1226361242-2516-3-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1226361242-2516-2-git-send-email-madcoder@debian.org","subject":"[PATCH 2/4] git send-email: interpret unknown files as revision lists","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-10T23:54:00Z","receivedAt":"2008-11-10T23:54:00Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"Filter out all the arguments git-send-email doesn't like to a\ngit format-patch command, that dumps its content to a safe directory.\n\nBarf when a file/revision conflict occurs, allow it to be overriden\n--[no-]format-patch.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-send-email.txt |    8 +++++-\n git-send-email.perl              |   47 +++++++++++++++++++++++++++++++++----\n t/t9001-send-email.sh            |    8 ++++++\n 3 files changed, 57 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 82f5056..0beaad4 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -8,7 +8,7 @@ git-send-email - Send a collection of patches as emails\n \n SYNOPSIS\n --------\n-'git send-email' [options] <file|directory> [... file|directory]\n+'git send-email' [options] <file|directory|rev-list options>...\n \n \n DESCRIPTION\n@@ -183,6 +183,12 @@ Administering\n --[no-]validate::\n \tPerform sanity checks on patches.\n \tCurrently, validation means the following:\n+\n+--[no-]format-patch::\n+\tWhen an argument may be understood either as a reference or as a file name,\n+\tchoose to understand it as a format-patch argument ('--format-patch')\n+\tor as a file name ('--no-format-patch'). By default, when such a conflict\n+\toccurs, git send-email will fail.\n +\n --\n \t\t*\tWarn of patches that contain lines longer than 998 characters; this\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex aaace02..6f5a613 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -22,8 +22,12 @@ use Term::ReadLine;\n use Getopt::Long;\n use Data::Dumper;\n use Term::ANSIColor;\n+use File::Temp qw/ tempdir /;\n+use Error qw(:try);\n use Git;\n \n+Getopt::Long::Configure qw/ pass_through /;\n+\n package FakeTerm;\n sub new {\n \tmy ($class, $reason) = @_;\n@@ -38,7 +42,7 @@ package main;\n \n sub usage {\n \tprint <<EOT;\n-git send-email [options] <file | directory>...\n+git send-email [options] <file | directory | rev-list options >\n \n   Composing:\n     --from                  <str>  * Email From:\n@@ -73,6 +77,8 @@ git send-email [options] <file | directory>...\n     --quiet                        * Output one line of info per email.\n     --dry-run                      * Don't actually send the emails.\n     --[no-]validate                * Perform patch sanity checks. Default on.\n+    --[no-]format-patch            * understand any non optional arguments as\n+                                     `git format-patch` ones.\n \n EOT\n \texit(1);\n@@ -146,6 +152,7 @@ if ($@) {\n \n # Behavior modification variables\n my ($quiet, $dry_run) = (0, 0);\n+my $format_patch;\n my $compose_filename = $repo->repo_path() . \"/.gitsendemail.msg.$$\";\n \n # Variables with corresponding config settings\n@@ -229,6 +236,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"envelope-sender=s\" => \\$envelope_sender,\n \t\t    \"thread!\" => \\$thread,\n \t\t    \"validate!\" => \\$validate,\n+\t\t    \"format-patch!\" => \\$format_patch,\n \t );\n \n unless ($rc) {\n@@ -363,23 +371,52 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\n \n ($sender) = expand_aliases($sender) if defined $sender;\n \n+# returns 1 if the conflict must be solved using it as a format-patch argument\n+sub check_file_rev_conflict($) {\n+\tmy $f = shift;\n+\ttry {\n+\t\t$repo->command('rev-parse', '--verify', '--quiet', $f);\n+\t\tif (defined($format_patch)) {\n+\t\t\tprint \"foo\\n\";\n+\t\t\treturn $format_patch;\n+\t\t}\n+\t\tdie(<<EOF);\n+File '$f' exists but it could also be the range of commits\n+to produce patches for.  Please disambiguate by...\n+\n+    * Saying \"./$f\" if you mean a file; or\n+    * Giving --format-patch option if you mean a range.\n+EOF\n+\t} catch Git::Error::Command with {\n+\t\treturn 0;\n+\t}\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-\tif (-d $f) {\n+my @rev_list_opts;\n+while (my $f = pop @ARGV) {\n+\tif ($f eq \"--\") {\n+\t\tpush @rev_list_opts, \"--\", @ARGV;\n+\t\t@ARGV = ();\n+\t} elsif (-d $f and !check_file_rev_conflict($f)) {\n \t\topendir(DH,$f)\n \t\t\tor die \"Failed to opendir $f: $!\";\n \n \t\tpush @files, grep { -f $_ } map { +$f . \"/\" . $_ }\n \t\t\t\tsort readdir(DH);\n \t\tclosedir(DH);\n-\t} elsif (-f $f or -p $f) {\n+\t} elsif ((-f $f or -p $f) and !check_file_rev_conflict($f)) {\n \t\tpush @files, $f;\n \t} else {\n-\t\tprint STDERR \"Skipping $f - not found.\\n\";\n+\t\tpush @rev_list_opts, $f;\n \t}\n }\n \n+if (@rev_list_opts) {\n+\tpush @files, $repo->command('format-patch', '-o', tempdir(CLEANUP => 1), @rev_list_opts);\n+}\n+\n if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 561ae7d..b4bddd1 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -292,4 +292,12 @@ test_expect_success '--compose adds MIME for utf8 subject' '\n \tgrep \"^Subject: =?utf-8?q?utf8-s=C3=BCbj=C3=ABct?=\" msgtxt1\n '\n \n+test_expect_success 'detects ambiguous reference/file conflict' '\n+\techo master > master &&\n+\tgit add master &&\n+\tgit commit -m\"add master\" &&\n+\ttest_must_fail git send-email --dry-run master > errors &&\n+\tgrep disambiguate errors\n+'\n+\n test_done\n-- \n1.6.0.4.859.g7ecd.dirty\n"},{"id":"95413","messageId":"1226361242-2516-4-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1226361242-2516-3-git-send-email-madcoder@debian.org","subject":"[PATCH 3/4] git send-email: add --annotate option","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-10T23:54:01Z","receivedAt":"2008-11-10T23:54:01Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"This allows to review every patch (and fix various aspects of them, or\ncomment them) in an editor just before being sent. Combined to the fact\nthat git send-email can now process revision lists, this makes git\nsend-email and efficient way to review and send patches interactively.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-send-email.txt |   11 +++++++++++\n git-send-email.perl              |   26 ++++++++++++++++++++++++--\n 2 files changed, 35 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 0beaad4..66d5f4c 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -37,6 +37,11 @@ The --bcc option must be repeated for each user you want on the bcc list.\n +\n The --cc option must be repeated for each user you want on the cc list.\n \n+--annotate::\n+\tReview each patch you're about to send in an editor. The setting\n+\t'sendemail.multiedit' defines if this will spawn one editor per patch\n+\tor one for all of them at once.\n+\n --compose::\n \tUse $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an\n \tintroductory message for the patch series.\n@@ -210,6 +215,12 @@ sendemail.aliasfiletype::\n \tFormat of the file(s) specified in sendemail.aliasesfile. Must be\n \tone of 'mutt', 'mailrc', 'pine', or 'gnus'.\n \n+sendemail.multiedit::\n+\tIf true (default), a single editor instance will be spawned to edit\n+\tfiles you have to edit (patches when '--annotate' is used, and the\n+\tsummary when '--compose' is used). If false, files will be edited one\n+\tafter the other, spawning a new editor each time.\n+\n \n Author\n ------\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 6f5a613..ccb3b18 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -51,6 +51,7 @@ git send-email [options] <file | directory | rev-list options >\n     --bcc                   <str>  * Email Bcc:\n     --subject               <str>  * Email \"Subject:\"\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n+    --annotate                     * Review each patch that will be sent in an editor.\n     --compose                      * Open an editor for introduction.\n \n   Sending:\n@@ -132,7 +133,8 @@ sub cleanup_compose_files();\n \n # Variables we fill in automatically, or via prompting:\n my (@to,@cc,@initial_cc,@bcclist,@xh,\n-\t$initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);\n+\t$initial_reply_to,$initial_subject,@files,\n+\t$author,$sender,$smtp_authpass,$annotate,$compose,$time);\n \n my $envelope_sender;\n \n@@ -155,6 +157,17 @@ my ($quiet, $dry_run) = (0, 0);\n my $format_patch;\n my $compose_filename = $repo->repo_path() . \"/.gitsendemail.msg.$$\";\n \n+# Handle interactive edition of files.\n+my $multiedit;\n+my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n+sub do_edit {\n+\tif (defined($multiedit) && !$multiedit) {\n+\t\tmap { system('sh', '-c', $editor.' \"$@\"', $editor, $_); } @_;\n+\t} else {\n+\t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, @_);\n+\t}\n+}\n+\n # Variables with corresponding config settings\n my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);\n my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);\n@@ -184,6 +197,7 @@ my %config_settings = (\n     \"aliasesfile\" => \\@alias_files,\n     \"suppresscc\" => \\@suppress_cc,\n     \"envelopesender\" => \\$envelope_sender,\n+    \"multiedit\" => \\$multiedit,\n );\n \n # Handle Uncouth Termination\n@@ -226,6 +240,7 @@ my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n \t\t    \"smtp-ssl\" => sub { $smtp_encryption = 'ssl' },\n \t\t    \"smtp-encryption=s\" => \\$smtp_encryption,\n \t\t    \"identity=s\" => \\$identity,\n+\t\t    \"annotate\" => \\$annotate,\n \t\t    \"compose\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n@@ -532,7 +547,12 @@ EOT\n \tclose(C);\n \n \tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n-\tsystem('sh', '-c', $editor.' \"$@\"', $editor, $compose_filename);\n+\n+\tif ($annotate) {\n+\t\tdo_edit($compose_filename, @files);\n+\t} else {\n+\t\tdo_edit($compose_filename);\n+\t}\n \n \topen(C2,\">\",$compose_filename . \".final\")\n \t\tor die \"Failed to open $compose_filename.final : \" . $!;\n@@ -581,6 +601,8 @@ EOT\n \t}\n \n \t@files = ($compose_filename . \".final\", @files);\n+} elsif ($annotate) {\n+\tdo_edit(@files);\n }\n \n # Variables we set as part of the loop over files\n-- \n1.6.0.4.859.g7ecd.dirty\n"},{"id":"95411","messageId":"1226361242-2516-5-git-send-email-madcoder@debian.org","threadId":"16108","inReplyTo":"1226361242-2516-4-git-send-email-madcoder@debian.org","subject":"[PATCH 4/4] git send-email: ask less questions when --compose is used.","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-10T23:54:02Z","receivedAt":"2008-11-10T23:54:02Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"When --compose is used, we can grab the From/Subject/In-Reply-To from the\nedited summary, let it be so and don't ask the user silly questions.\n\nThe summary templates gets quite revamped, and includes the list of\npatches subjects that are going to be sent with this batch.\n\nWhen having a body full of empty lines, the summary isn't sent. Document\nthat in the git-send-email manpage fully.\n\nNote: It doesn't deal with To/Cc/Bcc yet.\n\nSigned-off-by: Pierre Habouzit <madcoder@debian.org>\n---\n Documentation/git-send-email.txt |    9 ++\n git-send-email.perl              |  187 +++++++++++++++++++++++---------------\n 2 files changed, 123 insertions(+), 73 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 66d5f4c..acf8bf4 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -45,6 +45,15 @@ The --cc option must be repeated for each user you want on the cc list.\n --compose::\n \tUse $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an\n \tintroductory message for the patch series.\n++\n+When compose is in used, git send-email gets less interactive will use the\n+values of the headers you set there. If the body of the email (what you type\n+after the headers and a blank line) only contains blank (or GIT: prefixed)\n+lines, the summary won't be sent, but git-send-email will still use the\n+Headers values if you don't removed them.\n++\n+If it wasn't able to see a header in the summary it will ask you about it\n+interactively after quitting your editor.\n \n --from::\n \tSpecify the sender of the emails.  This will default to\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex ccb3b18..9039cfd 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -162,9 +162,17 @@ my $multiedit;\n my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n sub do_edit {\n \tif (defined($multiedit) && !$multiedit) {\n-\t\tmap { system('sh', '-c', $editor.' \"$@\"', $editor, $_); } @_;\n+\t\tmap {\n+\t\t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, $_);\n+\t\t\tif (($? & 127) || ($? >> 8)) {\n+\t\t\t\tdie(\"the editor exited uncleanly, aborting everything\");\n+\t\t\t}\n+\t\t} @_;\n \t} else {\n \t\tsystem('sh', '-c', $editor.' \"$@\"', $editor, @_);\n+\t\tif (($? & 127) || ($? >> 8)) {\n+\t\t\tdie(\"the editor exited uncleanly, aborting everything\");\n+\t\t}\n \t}\n }\n \n@@ -450,6 +458,108 @@ if (@files) {\n \tusage();\n }\n \n+sub get_patch_subject($) {\n+\tmy $fn = shift;\n+\topen (my $fh, '<', $fn);\n+\twhile (my $line = <$fh>) {\n+\t\tnext unless ($line =~ /^Subject: (.*)$/);\n+\t\tclose $fh;\n+\t\treturn \"GIT: $1\\n\";\n+\t}\n+\tclose $fh;\n+\tdie \"No subject line in $fn ?\";\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+\n+\n+\tmy $tpl_sender = $sender || $repoauthor || $repocommitter || '';\n+\tmy $tpl_subject = $initial_subject || '';\n+\tmy $tpl_reply_to = $initial_reply_to || '';\n+\n+\tprint C <<EOT;\n+From $tpl_sender # This line is ignored.\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+GIT:\n+GIT: Clear the body content if you don't wish to send a summary.\n+From: $tpl_sender\n+Subject: $tpl_subject\n+In-Reply-To: $tpl_reply_to\n+\n+EOT\n+\tfor my $f (@files) {\n+\t\tprint C get_patch_subject($f);\n+\t}\n+\tclose(C);\n+\n+\tmy $editor = $ENV{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n+\n+\tif ($annotate) {\n+\t\tdo_edit($compose_filename, @files);\n+\t} else {\n+\t\tdo_edit($compose_filename);\n+\t}\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+\tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n+\tmy $in_body = 0;\n+\tmy $summary_empty = 1;\n+\twhile(<C>) {\n+\t\tnext if m/^GIT: /;\n+\t\tif ($in_body) {\n+\t\t\t$summary_empty = 0 unless (/^\\n$/);\n+\t\t} elsif (/^\\n$/) {\n+\t\t\t$in_body = 1;\n+\t\t\tif ($need_8bit_cte) {\n+\t\t\t\tprint C2 \"MIME-Version: 1.0\\n\",\n+\t\t\t\t\t \"Content-Type: text/plain; \",\n+\t\t\t\t\t   \"charset=utf-8\\n\",\n+\t\t\t\t\t \"Content-Transfer-Encoding: 8bit\\n\";\n+\t\t\t}\n+\t\t} elsif (/^MIME-Version:/i) {\n+\t\t\t$need_8bit_cte = 0;\n+\t\t} elsif (/^Subject:\\s*(.+)\\s*$/i) {\n+\t\t\t$initial_subject = $1;\n+\t\t\tmy $subject = $initial_subject;\n+\t\t\t$_ = \"Subject: \" .\n+\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n+\t\t\t\t quote_rfc2047($subject) :\n+\t\t\t\t $subject) .\n+\t\t\t\t\"\\n\";\n+\t\t} elsif (/^In-Reply-To:\\s*(.+)\\s*$/i) {\n+\t\t\t$initial_reply_to = $1;\n+\t\t\tnext;\n+\t\t} elsif (/^From:\\s*(.+)\\s*$/i) {\n+\t\t\t$sender = $1;\n+\t\t\tnext;\n+\t\t} elsif (/^(?:To|Cc|Bcc):/i) {\n+\t\t\tprint \"To/Cc/Bcc fields are not interpreted yet, they have been ignored\\n\";\n+\t\t\tnext;\n+\t\t}\n+\t\tprint C2 $_;\n+\t}\n+\tclose(C);\n+\tclose(C2);\n+\n+\tif ($summary_empty) {\n+\t\tprint \"Summary email is empty, skipping it\\n\";\n+\t\t$compose = -1;\n+\t}\n+} elsif ($annotate) {\n+\tdo_edit(@files);\n+}\n+\n my $prompting = 0;\n if (!defined $sender) {\n \t$sender = $repoauthor || $repocommitter || '';\n@@ -494,17 +604,6 @@ sub expand_aliases {\n @initial_cc = expand_aliases(@initial_cc);\n @bcclist = expand_aliases(@bcclist);\n \n-if (!defined $initial_subject && $compose) {\n-\twhile (1) {\n-\t\t$_ = $term->readline(\"What subject should the initial email start with? \", $initial_subject);\n-\t\tlast if defined $_;\n-\t\tprint \"\\n\";\n-\t}\n-\n-\t$initial_subject = $_;\n-\t$prompting++;\n-}\n-\n if ($thread && !defined $initial_reply_to && $prompting) {\n \twhile (1) {\n \t\t$_= $term->readline(\"Message-ID to be used as In-Reply-To for the first email? \", $initial_reply_to);\n@@ -531,64 +630,6 @@ if (!defined $smtp_server) {\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 $sender # This line is ignored.\\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{GIT_EDITOR} || Git::config(@repo, \"core.editor\") || $ENV{VISUAL} || $ENV{EDITOR} || \"vi\";\n-\n-\tif ($annotate) {\n-\t\tdo_edit($compose_filename, @files);\n-\t} else {\n-\t\tdo_edit($compose_filename);\n-\t}\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-\tmy $need_8bit_cte = file_has_nonascii($compose_filename);\n-\tmy $in_body = 0;\n-\twhile(<C>) {\n-\t\tnext if m/^GIT: /;\n-\t\tif (!$in_body && /^\\n$/) {\n-\t\t\t$in_body = 1;\n-\t\t\tif ($need_8bit_cte) {\n-\t\t\t\tprint C2 \"MIME-Version: 1.0\\n\",\n-\t\t\t\t\t \"Content-Type: text/plain; \",\n-\t\t\t\t\t   \"charset=utf-8\\n\",\n-\t\t\t\t\t \"Content-Transfer-Encoding: 8bit\\n\";\n-\t\t\t}\n-\t\t}\n-\t\tif (!$in_body && /^MIME-Version:/i) {\n-\t\t\t$need_8bit_cte = 0;\n-\t\t}\n-\t\tif (!$in_body && /^Subject: ?(.*)/i) {\n-\t\t\tmy $subject = $1;\n-\t\t\t$_ = \"Subject: \" .\n-\t\t\t\t($subject =~ /[^[:ascii:]]/ ?\n-\t\t\t\t quote_rfc2047($subject) :\n-\t\t\t\t $subject) .\n-\t\t\t\t\"\\n\";\n-\t\t}\n-\t\tprint C2 $_;\n-\t}\n-\tclose(C);\n-\tclose(C2);\n-\n \twhile (1) {\n \t\t$_ = $term->readline(\"Send this email? (y|n) \");\n \t\tlast if defined $_;\n@@ -600,9 +641,9 @@ EOT\n \t\texit(0);\n \t}\n \n-\t@files = ($compose_filename . \".final\", @files);\n-} elsif ($annotate) {\n-\tdo_edit(@files);\n+\tif ($compose > 0) {\n+\t\t@files = ($compose_filename . \".final\", @files);\n+\t}\n }\n \n # Variables we set as part of the loop over files\n-- \n1.6.0.4.859.g7ecd.dirty\n"},{"id":"95484","messageId":"7v4p2e0zus.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"1226361242-2516-1-git-send-email-madcoder@debian.org","subject":"Re: [take 2] git send-email updates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-11T20:30:51Z","receivedAt":"2008-11-11T20:30:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> The last patch is dropped for now (the automatic --compose stuff)\n> because I'm not sure which option to add, and that I don't care enough\n> about it to spend more time on it.\n>\n> I think I've incorporated most of the stuff people asked about in this\n> series.\n>\n>  [PATCH 1/4] git send-email: make the message file name more specific.\n>  [PATCH 2/4] git send-email: interpret unknown files as revision lists\n>  [PATCH 3/4] git send-email: add --annotate option\n>  [PATCH 4/4] git send-email: ask less questions when --compose is used.\n\nThanks.\n\nIt is somewhat unfortunate that an explicit --no-format-patch works\nexactly the same way as not giving the option at all.  I would have\nexpected that it would guess and warn if you did not give either, and it\nwould not even guess (i.e. file is mbox, dir is maildir) and error out if\nthere is a leftover option in @rev_list_opts if the user explicitly asked\nthe command not act as a frontend to format patch.\n\nI will queue the series in 'pu' because I suspect you would like a chance\nto amend out a \"print foo\" from the second commit ;-)\n"},{"id":"95499","messageId":"20081111221351.GE10073@artemis.corp","threadId":"16108","inReplyTo":"7v4p2e0zus.fsf@gitster.siamese.dyndns.org","subject":"Re: [take 2] git send-email updates","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-11T22:13:51Z","receivedAt":"2008-11-11T22:13:51Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Tue, Nov 11, 2008 at 08:30:51PM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > The last patch is dropped for now (the automatic --compose stuff)\n> > because I'm not sure which option to add, and that I don't care enough\n> > about it to spend more time on it.\n> >\n> > I think I've incorporated most of the stuff people asked about in this\n> > series.\n> >\n> >  [PATCH 1/4] git send-email: make the message file name more specific.\n> >  [PATCH 2/4] git send-email: interpret unknown files as revision lists\n> >  [PATCH 3/4] git send-email: add --annotate option\n> >  [PATCH 4/4] git send-email: ask less questions when --compose is used.\n> \n> Thanks.\n> \n> It is somewhat unfortunate that an explicit --no-format-patch works\n> exactly the same way as not giving the option at all.\n\nUnless I'm mistaken in my code, and I may really be, it doesn't.\n--format-patch says that in case of conflicts, the \"revision\" kind of\nargument wins, --no-format-patch says that the \"file\" one wins, without\nany it dies with an error. It's really a tristate, but maybe I missed\nyour point ?\n\n> I would have expected that it would guess and warn if you did not give\n> either, and it would not even guess (i.e. file is mbox, dir is\n> maildir) and error out if there is a leftover option in @rev_list_opts\n> if the user explicitly asked the command not act as a frontend to\n> format patch.\n\nOh you mean that if one use --no-format-patch you don't wan't _any_\noption to be passed to format-patch ? Hmmm I don't know, both what I did\nand that are sane, I don't really know what to chose. But if we're going\nto go down this road, _your_ --no-format-patch and --format-patch don't\nquite do the opposite, as --format-patch still allows files to be passed\nto it.\n\nIf we're really doing this, then maybe we want a 5-state kind of option:\n  1 disallow any file name ;\n  2 if conflict, chose the revision ;\n  3 barf if any conflict arises (default) ;\n  4 if conflict chose the file ;\n  5 disallow any kind of revision argument.\n\nMy proposal implements 2 as --format-patch, 3 as default, and 4 as\n--no-format-patch. You propose basically (5) for --no-format-patch\ninstead, well I say this makes sense, but it's somehow \"sad\" not to have\n(1) too in that case.\n\nBut in the end, I believe this _may_ quite be slightly over-engineered in\nthe end ;) I would gladly implement the combination people like most, as\nsoon as I can pass format-patch option a way or the other, I'm happy :)\n\n> I will queue the series in 'pu' because I suspect you would like a chance\n> to amend out a \"print foo\" from the second commit ;-)\n\n*ooops*\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"95511","messageId":"7vk5b9x0kj.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"20081111221351.GE10073@artemis.corp","subject":"Re: [take 2] git send-email updates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-12T00:14:20Z","receivedAt":"2008-11-12T00:14:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> Oh you mean that if one use --no-format-patch you don't wan't _any_\n> option to be passed to format-patch?\n\nThe option name --no-format-patch sounded like \"I do not want you to act\nas a frontend, ever\", i.e. if you type master..next by mistake on the\ncommand line, the command would barf when the option is given.  Not even\n\"pass to format-patch\", but \"do not run format-patch to begin with\".\n\nIt is not a big deal especially for interactive use (and that is why I\nsaid \"somewhat\" unfortunate).\n\n> If we're really doing this, then maybe we want a 5-state kind of option:\n>   1 disallow any file name ;\n>   2 if conflict, chose the revision ;\n>   3 barf if any conflict arises (default) ;\n>   4 if conflict chose the file ;\n>   5 disallow any kind of revision argument.\n>\n> My proposal implements 2 as --format-patch, 3 as default, and 4 as\n> --no-format-patch. You propose basically (5) for --no-format-patch\n> instead, well I say this makes sense, but it's somehow \"sad\" not to have\n> (1) too in that case.\n\nActually, \"send-email --format-patch master..fixes Documentation/\" may be\na useful command to send out only documentation fixes.  For such a usage,\nDocumentation/ should not be taken as a maildir.  If we would want to\nsupport such usage (and I'd say why not), a token can fall into one (or\ntwo) of three categories:\n\n    - can it be a rev?\n\n    - is it a tracked path (either blob or a leading dir)?\n\n    - is it a file/dir that is not tracked?\n\nThe first two would be format-patch candidate.  The last one is the\ntraditional mail source.  Because the latter two are disjoint set, and\nbecause it does not matter if you have a tracked file 'master' and a\nbranch 'master' in your repo (either will be passed to format-patch\nanyway), the actual disambiguity is reduced, but it still is different\nfrom what you have in your patch, I suspect.\n\nAs to options, how about doing this:\n\n    --no-format-patch means never ever run format-patch, behave exactly as\n    before;\n\n    --format-patch means what you have in your patch.  guess and favor \n    format-patch parameter when ambiguous;\n\n    without either option, guess and favor mbox/maildir but still run\n    format-patch if remaining parameters and options need to\n    (e.g. \"send-email my-cover-letter origin/master..master\" will find\n    my-cover-letter which is not tracked and take it as mbox, and grab\n    patches from commits between origin/master..master, and send all of\n    them).\n"},{"id":"95527","messageId":"7vd4h1sder.fsf@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"1226361242-2516-3-git-send-email-madcoder@debian.org","subject":"Re: [PATCH 2/4] git send-email: interpret unknown files as revision lists","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-12T05:48:12Z","receivedAt":"2008-11-12T05:48:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pierre Habouzit <madcoder@debian.org> writes:\n\n> +test_expect_success 'detects ambiguous reference/file conflict' '\n> +\techo master > master &&\n> +\tgit add master &&\n> +\tgit commit -m\"add master\" &&\n> +\ttest_must_fail git send-email --dry-run master > errors &&\n> +\tgrep disambiguate errors\n> +'\n\nI've queued the series in 'pu', but with a fix to this test, without which\nit did not pass (and I had to rewind and rebuild 'pu').\n"},{"id":"95650","messageId":"7vfxlwlcid.fsf_-_@gitster.siamese.dyndns.org","threadId":"16108","inReplyTo":"7vk5b9x0kj.fsf@gitster.siamese.dyndns.org","subject":"Re* [take 2] git send-email updates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-13T00:01:46Z","receivedAt":"2008-11-13T00:01:46Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Actually, \"send-email --format-patch master..fixes Documentation/\" may be\n> a useful command to send out only documentation fixes.  For such a usage,\n> Documentation/ should not be taken as a maildir.  If we would want to\n> support such usage (and I'd say why not), a token can fall into one (or\n> two) of three categories:\n>\n>     - can it be a rev?\n>\n>     - is it a tracked path (either blob or a leading dir)?\n>\n>     - is it a file/dir that is not tracked?\n>\n> The first two would be format-patch candidate.  The last one is the\n> traditional mail source.  Because the latter two are disjoint set, and\n> because it does not matter if you have a tracked file 'master' and a\n> branch 'master' in your repo (either will be passed to format-patch\n> anyway), the actual disambiguity is reduced, but it still is different\n> from what you have in your patch, I suspect.\n>\n> As to options, how about doing this:\n>\n>     --no-format-patch means never ever run format-patch, behave exactly as\n>     before;\n>\n>     --format-patch means what you have in your patch.  guess and favor \n>     format-patch parameter when ambiguous;\n>\n>     without either option, guess and favor mbox/maildir but still run\n>     format-patch if remaining parameters and options need to\n>     (e.g. \"send-email my-cover-letter origin/master..master\" will find\n>     my-cover-letter which is not tracked and take it as mbox, and grab\n>     patches from commits between origin/master..master, and send all of\n>     them).\n\nThis patch on top of your [2/4] illustrates what I had in mind (it also\nremoves the \"print foo\" while at it).\n\n git-send-email.perl |   35 +++++++++++++++++++++++++++++++----\n 1 files changed, 31 insertions(+), 4 deletions(-)\n\ndiff --git c/git-send-email.perl w/git-send-email.perl\nindex 6f5a613..9aa3500 100755\n--- c/git-send-email.perl\n+++ w/git-send-email.perl\n@@ -152,7 +152,7 @@ if ($@) {\n \n # Behavior modification variables\n my ($quiet, $dry_run) = (0, 0);\n-my $format_patch;\n+my $format_patch = 'unspecified';\n my $compose_filename = $repo->repo_path() . \"/.gitsendemail.msg.$$\";\n \n # Variables with corresponding config settings\n@@ -243,6 +243,15 @@ unless ($rc) {\n     usage();\n }\n \n+if ($format_patch && $format_patch eq 'unspecified') {\n+\t# No --format-patch nor --no-format-patch on the command line\n+\t$format_patch = 0;\n+} elsif (!$format_patch) {\n+\t$format_patch = undef;\n+} else {\n+\t$format_patch = 1;\n+}\n+\n # Now, let's fill any that aren't set in with defaults:\n \n sub read_config {\n@@ -374,11 +383,27 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\n # returns 1 if the conflict must be solved using it as a format-patch argument\n sub check_file_rev_conflict($) {\n \tmy $f = shift;\n+\n+\tif (!defined $format_patch) {\n+\t\t# The command line explicitly forbids acting as a wrapper\n+\t\treturn 0;\n+\t}\n+\n+\t# If it is a tracked path it can't be tracking the e-mails you\n+\t# are going to send out to describe the change to this repository.\n+\teval {\n+\t\t$repo->command(['ls-files', '--error-unmatch', $f],\n+\t\t\t       { STDERR => 0 });\n+\t};\n+\tif (!$@) {\n+\t\treturn 1;\n+\t}\n+\n+\t# Can it be interpreted as a rev?\n \ttry {\n \t\t$repo->command('rev-parse', '--verify', '--quiet', $f);\n-\t\tif (defined($format_patch)) {\n-\t\t\tprint \"foo\\n\";\n-\t\t\treturn $format_patch;\n+\t\tif ($format_patch) {\n+\t\t\treturn 1;\n \t\t}\n \t\tdie(<<EOF);\n File '$f' exists but it could also be the range of commits\n@@ -408,6 +433,8 @@ while (my $f = pop @ARGV) {\n \t\tclosedir(DH);\n \t} elsif ((-f $f or -p $f) and !check_file_rev_conflict($f)) {\n \t\tpush @files, $f;\n+\t} elsif (!defined $format_patch) {\n+\t\tdie(\"--no-format-patch was given but $f is not a valid send-email argument\");\n \t} else {\n \t\tpush @rev_list_opts, $f;\n \t}\n"},{"id":"95902","messageId":"20081115220510.GA11895@artemis.corp","threadId":"16108","inReplyTo":"7vk5b9x0kj.fsf@gitster.siamese.dyndns.org","subject":"Re: [take 2] git send-email updates","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-15T22:05:10Z","receivedAt":"2008-11-15T22:05:10Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Wed, Nov 12, 2008 at 12:14:20AM +0000, Junio C Hamano wrote:\n> Pierre Habouzit <madcoder@debian.org> writes:\n> \n> > Oh you mean that if one use --no-format-patch you don't wan't _any_\n> > option to be passed to format-patch?\n> \n> The option name --no-format-patch sounded like \"I do not want you to act\n> as a frontend, ever\", i.e. if you type master..next by mistake on the\n> command line, the command would barf when the option is given.  Not even\n> \"pass to format-patch\", but \"do not run format-patch to begin with\".\n> \n> It is not a big deal especially for interactive use (and that is why I\n> said \"somewhat\" unfortunate).\n> \n> > If we're really doing this, then maybe we want a 5-state kind of option:\n> >   1 disallow any file name ;\n> >   2 if conflict, chose the revision ;\n> >   3 barf if any conflict arises (default) ;\n> >   4 if conflict chose the file ;\n> >   5 disallow any kind of revision argument.\n> >\n> > My proposal implements 2 as --format-patch, 3 as default, and 4 as\n> > --no-format-patch. You propose basically (5) for --no-format-patch\n> > instead, well I say this makes sense, but it's somehow \"sad\" not to have\n> > (1) too in that case.\n> \n> Actually, \"send-email --format-patch master..fixes Documentation/\" may be\n> a useful command to send out only documentation fixes.  For such a usage,\n> Documentation/ should not be taken as a maildir.  If we would want to\n> support such usage (and I'd say why not), a token can fall into one (or\n> two) of three categories:\n\nYou can do that doing:\n\ngit send-email --format-patch master..fixes -- Documentation/\n\nI've kept the `--` usual meaning, and it's sent to git-format-patch\nverbatim and it'll work, so it's not required to change the meaning of\nthe options for that.\n\n[sorry for the late reply, I've been somehow busy lately]\n\nThe sole conflict we have is when there is a path/rev conflict *before*\nthe `--` because of the legacy of git-send-email. I believe that\n--format-patch should still allow to send patches passed on the command\nline, this way.\n\n> As to options, how about doing this:\n> \n>     --no-format-patch means never ever run format-patch, behave exactly as\n>     before;\n> \n>     --format-patch means what you have in your patch.  guess and favor \n>     format-patch parameter when ambiguous;\n> \n>     without either option, guess and favor mbox/maildir but still run\n>     format-patch if remaining parameters and options need to\n>     (e.g. \"send-email my-cover-letter origin/master..master\" will find\n>     my-cover-letter which is not tracked and take it as mbox, and grab\n>     patches from commits between origin/master..master, and send all of\n>     them).\n\nThat's sane and I like it.\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"95903","messageId":"20081115220723.GB11895@artemis.corp","threadId":"16108","inReplyTo":"7vfxlwlcid.fsf_-_@gitster.siamese.dyndns.org","subject":"Re: Re* [take 2] git send-email updates","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-15T22:07:23Z","receivedAt":"2008-11-15T22:07:23Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Thu, Nov 13, 2008 at 12:01:46AM +0000, Junio C Hamano wrote:\n> This patch on top of your [2/4] illustrates what I had in mind (it also\n> removes the \"print foo\" while at it).\n\nI like it.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"}]}