git-send-email: make options easier to configure.
This change makes git-send-email's behavior easier to modify by adding config equivalents for two more of git-send-email's flags. The mapping of flag to config setting is: --[no-]supress-from => sendemail.suppressfrom --[no-]signed-off-cc => sendemail.signedoffcc It renames the --threaded option to --thread/--no-thread; the config variable is also called sendemail.thread. Signed-off-by: Adam Roben <aroben@apple.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Adam Roben committed
Jun 27, 2007 at 20:59 UTC
5483c71d7ac06b4f16c646886abbb2d0f88a2855
2 files changed
+36
-30
Documentation/git-send-email.txt
+14
-10
@@ -59,9 +59,11 @@ The --cc option must be repeated for each user you want on the cc list.
59
Only necessary if --compose is also set. If --compose
60
is not set, this will be prompted for.
61
62
---no-signed-off-by-cc::
63
- Do not add emails found in Signed-off-by: or Cc: lines to the
64
- cc list.
62
+--signed-off-by-cc, --no-signed-off-by-cc::
63
+ If this is set, add emails found in Signed-off-by: or Cc: lines to the
64
+ cc list.
65
+ Default is the value of 'sendemail.signedoffbycc' configuration value;
66
+ if that is unspecified, default to --signed-off-by-cc.
67
68
--quiet::
69
Make git-send-email less verbose. One line per email should be
@@ -82,16 +84,18 @@ The --cc option must be repeated for each user you want on the cc list.
84
Only necessary if --compose is also set. If --compose
85
is not set, this will be prompted for.
86
85
---suppress-from::
86
- Do not add the From: address to the cc: list, if it shows up in a From:
87
- line.
87
+--suppress-from, --no-suppress-from::
88
+ If this is set, do not add the From: address to the cc: list, if it
89
+ shows up in a From: line.
90
+ Default is the value of 'sendemail.suppressfrom' configuration value;
91
+ if that is unspecified, default to --no-supress-from.
92
89
---threaded, --no-threaded::
93
+--thread, --no-thread::
94
If this is set, the In-Reply-To header will be set on each email sent.
91
- If disabled with "--no-threaded", no emails will have the In-Reply-To
95
+ If disabled with "--no-thread", no emails will have the In-Reply-To
96
header set.
93
- Default is the value of the 'sendemail.threaded' configuration value;
94
- if that is unspecified, default to --threaded.
97
+ Default is the value of the 'sendemail.thread' configuration value;
98
+ if that is unspecified, default to --thread.
99
100
--dry-run::
101
Do everything except actually send the emails.
git-send-email.perl
+22
-20
@@ -64,17 +64,16 @@ Options:
64
email sent, rather than to the first email sent.
65
Defaults to on.
66
67
- --no-signed-off-cc Suppress the automatic addition of email addresses
68
- that appear in Signed-off-by: or Cc: lines to the cc:
69
- list. Note: Using this option is not recommended.
67
+ --signed-off-cc Automatically add email addresses that appear in
68
+ Signed-off-by: or Cc: lines to the cc: list. Defaults to on.
69
70
--smtp-server If set, specifies the outgoing SMTP server to use.
71
Defaults to localhost.
72
73
--suppress-from Suppress sending emails to yourself if your address
75
- appears in a From: line.
74
+ appears in a From: line. Defaults to off.
75
77
- --threaded Specify that the "In-Reply-To:" header should be set on all
76
+ --thread Specify that the "In-Reply-To:" header should be set on all
77
emails. Defaults to on.
78
79
--quiet Make git-send-email less verbose. One line per email
@@ -140,9 +139,6 @@ my $compose_filename = ".msg.$$";
139
my (@to,@cc,@initial_cc,@bcclist,@xh,
140
$initial_reply_to,$initial_subject,@files,$from,$compose,$time);
141
143
-# Behavior modification variables
144
-my ($threaded, $chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc,
145
- $dry_run) = (1, 1, 0, 0, 0, 0);
142
my $smtp_server;
143
my $envelope_sender;
144
@@ -157,16 +153,22 @@ if ($@) {
153
$term = new FakeTerm "$@: going non-interactive";
154
}
155
156
+# Behavior modification variables
157
+my ($quiet, $dry_run) = (0, 0);
158
+
159
+# Variables with corresponding config settings
160
+my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc);
161
+
162
my %config_settings = (
161
- "threaded" => \$threaded,
162
- "chainreplyto" => \$chain_reply_to,
163
+ "thread" => [\$thread, 1],
164
+ "chainreplyto" => [\$chain_reply_to, 1],
165
+ "suppressfrom" => [\$suppress_from, 0],
166
+ "signedoffcc" => [\$signed_off_cc, 1],
167
);
168
169
foreach my $setting (keys %config_settings) {
166
- my $default = $repo->config_bool("sendemail.$setting");
167
- if (defined $default) {
168
- $config_settings{$setting} = $default ? 1 : 0;
169
- }
170
+ my $config = $repo->config_bool("sendemail.$setting");
171
+ ${$config_settings{$setting}->[0]} = (defined $config) ? $config : $config_settings{$setting}->[1];
172
}
173
174
@bcclist = $repo->config('sendemail.bcc');
@@ -187,11 +189,11 @@ my $rc = GetOptions("from=s" => \$from,
189
"smtp-server=s" => \$smtp_server,
190
"compose" => \$compose,
191
"quiet" => \$quiet,
190
- "suppress-from" => \$suppress_from,
191
- "no-signed-off-cc|no-signed-off-by-cc" => \$no_signed_off_cc,
192
+ "suppress-from!" => \$suppress_from,
193
+ "signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
194
"dry-run" => \$dry_run,
195
"envelope-sender=s" => \$envelope_sender,
194
- "threaded!" => \$threaded,
196
+ "thread!" => \$thread,
197
);
198
199
unless ($rc) {
@@ -298,7 +300,7 @@ if (!defined $initial_subject && $compose) {
300
$prompting++;
301
}
302
301
-if ($threaded && !defined $initial_reply_to && $prompting) {
303
+if ($thread && !defined $initial_reply_to && $prompting) {
304
do {
305
$_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ",
306
$initial_reply_to);
@@ -495,7 +497,7 @@ Date: $date
497
Message-Id: $message_id
498
X-Mailer: git-send-email $gitversion
499
";
498
- if ($threaded && $reply_to) {
500
+ if ($thread && $reply_to) {
501
502
$header .= "In-Reply-To: $reply_to\n";
503
$header .= "References: $references\n";
@@ -620,7 +622,7 @@ foreach my $t (@files) {
622
}
623
} else {
624
$message .= $_;
623
- if (/^(Signed-off-by|Cc): (.*)$/i && !$no_signed_off_cc) {
625
+ if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
626
my $c = $2;
627
chomp $c;
628
push @cc, $c;