git send-email: add --annotate option
This allows to review every patch (and fix various aspects of them, or comment them) in an editor just before being sent. Combined to the fact that git send-email can now process revision lists, this makes git send-email and efficient way to review and send patches interactively. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pierre Habouzit committed
Nov 11, 2008 at 00:54 UTC
8fd5bb7f44b7192a564ebe4f9db376af9fe148ec
2 files changed
+35
-2
Documentation/git-send-email.txt
+11
@@ -37,6 +37,11 @@ The --bcc option must be repeated for each user you want on the bcc list.
37
+
38
The --cc option must be repeated for each user you want on the cc list.
39
40
+--annotate::
41
+ Review each patch you're about to send in an editor. The setting
42
+ 'sendemail.multiedit' defines if this will spawn one editor per patch
43
+ or one for all of them at once.
44
+
45
--compose::
46
Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
47
introductory message for the patch series.
@@ -210,6 +215,12 @@ sendemail.aliasfiletype::
215
Format of the file(s) specified in sendemail.aliasesfile. Must be
216
one of 'mutt', 'mailrc', 'pine', or 'gnus'.
217
218
+sendemail.multiedit::
219
+ If true (default), a single editor instance will be spawned to edit
220
+ files you have to edit (patches when '--annotate' is used, and the
221
+ summary when '--compose' is used). If false, files will be edited one
222
+ after the other, spawning a new editor each time.
223
+
224
225
Author
226
------
git-send-email.perl
+24
-2
@@ -51,6 +51,7 @@ git send-email [options] <file | directory | rev-list options >
51
--bcc <str> * Email Bcc:
52
--subject <str> * Email "Subject:"
53
--in-reply-to <str> * Email "In-Reply-To:"
54
+ --annotate * Review each patch that will be sent in an editor.
55
--compose * Open an editor for introduction.
56
57
Sending:
@@ -132,7 +133,8 @@ sub cleanup_compose_files();
133
134
# Variables we fill in automatically, or via prompting:
135
my (@to,@cc,@initial_cc,@bcclist,@xh,
135
- $initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);
136
+ $initial_reply_to,$initial_subject,@files,
137
+ $author,$sender,$smtp_authpass,$annotate,$compose,$time);
138
139
my $envelope_sender;
140
@@ -155,6 +157,17 @@ my ($quiet, $dry_run) = (0, 0);
157
my $format_patch;
158
my $compose_filename = $repo->repo_path() . "/.gitsendemail.msg.$$";
159
160
+# Handle interactive edition of files.
161
+my $multiedit;
162
+my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
163
+sub do_edit {
164
+ if (defined($multiedit) && !$multiedit) {
165
+ map { system('sh', '-c', $editor.' "$@"', $editor, $_); } @_;
166
+ } else {
167
+ system('sh', '-c', $editor.' "$@"', $editor, @_);
168
+ }
169
+}
170
+
171
# Variables with corresponding config settings
172
my ($thread, $chain_reply_to, $suppress_from, $signed_off_by_cc, $cc_cmd);
173
my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
@@ -184,6 +197,7 @@ my %config_settings = (
197
"aliasesfile" => \@alias_files,
198
"suppresscc" => \@suppress_cc,
199
"envelopesender" => \$envelope_sender,
200
+ "multiedit" => \$multiedit,
201
);
202
203
# Handle Uncouth Termination
@@ -226,6 +240,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
240
"smtp-ssl" => sub { $smtp_encryption = 'ssl' },
241
"smtp-encryption=s" => \$smtp_encryption,
242
"identity=s" => \$identity,
243
+ "annotate" => \$annotate,
244
"compose" => \$compose,
245
"quiet" => \$quiet,
246
"cc-cmd=s" => \$cc_cmd,
@@ -532,7 +547,12 @@ EOT
547
close(C);
548
549
my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
535
- system('sh', '-c', $editor.' "$@"', $editor, $compose_filename);
550
+
551
+ if ($annotate) {
552
+ do_edit($compose_filename, @files);
553
+ } else {
554
+ do_edit($compose_filename);
555
+ }
556
557
open(C2,">",$compose_filename . ".final")
558
or die "Failed to open $compose_filename.final : " . $!;
@@ -581,6 +601,8 @@ EOT
601
}
602
603
@files = ($compose_filename . ".final", @files);
604
+} elsif ($annotate) {
605
+ do_edit(@files);
606
}
607
608
# Variables we set as part of the loop over files