Skip to content

Commit 5483c71

Browse files
arobengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fe5e7f3 commit 5483c71

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

Documentation/git-send-email.txt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ The --cc option must be repeated for each user you want on the cc list.
5959
Only necessary if --compose is also set. If --compose
6060
is not set, this will be prompted for.
6161

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.
6567

6668
--quiet::
6769
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.
8284
Only necessary if --compose is also set. If --compose
8385
is not set, this will be prompted for.
8486

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.
8892

89-
--threaded, --no-threaded::
93+
--thread, --no-thread::
9094
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
9296
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.
9599

96100
--dry-run::
97101
Do everything except actually send the emails.

git-send-email.perl

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,16 @@ sub usage {
6464
email sent, rather than to the first email sent.
6565
Defaults to on.
6666
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.
7069
7170
--smtp-server If set, specifies the outgoing SMTP server to use.
7271
Defaults to localhost.
7372
7473
--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.
7675
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
7877
emails. Defaults to on.
7978
8079
--quiet Make git-send-email less verbose. One line per email
@@ -140,9 +139,6 @@ sub format_2822_time {
140139
my (@to,@cc,@initial_cc,@bcclist,@xh,
141140
$initial_reply_to,$initial_subject,@files,$from,$compose,$time);
142141

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);
146142
my $smtp_server;
147143
my $envelope_sender;
148144

@@ -157,16 +153,22 @@ sub format_2822_time {
157153
$term = new FakeTerm "$@: going non-interactive";
158154
}
159155

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+
160162
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],
163167
);
164168

165169
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];
170172
}
171173

172174
@bcclist = $repo->config('sendemail.bcc');
@@ -187,11 +189,11 @@ sub format_2822_time {
187189
"smtp-server=s" => \$smtp_server,
188190
"compose" => \$compose,
189191
"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,
192194
"dry-run" => \$dry_run,
193195
"envelope-sender=s" => \$envelope_sender,
194-
"threaded!" => \$threaded,
196+
"thread!" => \$thread,
195197
);
196198

197199
unless ($rc) {
@@ -298,7 +300,7 @@ sub expand_aliases {
298300
$prompting++;
299301
}
300302

301-
if ($threaded && !defined $initial_reply_to && $prompting) {
303+
if ($thread && !defined $initial_reply_to && $prompting) {
302304
do {
303305
$_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ",
304306
$initial_reply_to);
@@ -495,7 +497,7 @@ sub send_message
495497
Message-Id: $message_id
496498
X-Mailer: git-send-email $gitversion
497499
";
498-
if ($threaded && $reply_to) {
500+
if ($thread && $reply_to) {
499501

500502
$header .= "In-Reply-To: $reply_to\n";
501503
$header .= "References: $references\n";
@@ -620,7 +622,7 @@ sub send_message
620622
}
621623
} else {
622624
$message .= $_;
623-
if (/^(Signed-off-by|Cc): (.*)$/i && !$no_signed_off_cc) {
625+
if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
624626
my $c = $2;
625627
chomp $c;
626628
push @cc, $c;

0 commit comments

Comments
 (0)