Skip to content

Commit e46f7a0

Browse files
arobengitster
authored andcommitted
git-send-email: Add --threaded option
The --threaded option controls whether the In-Reply-To header will be set on any emails sent. The current behavior is to always set this header, so this option is most useful in its negated form, --no-threaded. This behavior can also be controlled through the 'sendemail.threaded' config setting. Signed-off-by: Adam Roben <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 384f122 commit e46f7a0

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

Documentation/git-send-email.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ The --cc option must be repeated for each user you want on the cc list.
8686
Do not add the From: address to the cc: list, if it shows up in a From:
8787
line.
8888

89+
--threaded, --no-threaded::
90+
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
92+
header set.
93+
Default is the value of the 'sendemail.threaded' configuration value;
94+
if that is unspecified, default to --threaded.
95+
8996
--dry-run::
9097
Do everything except actually send the emails.
9198

git-send-email.perl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ sub usage {
7474
--suppress-from Suppress sending emails to yourself if your address
7575
appears in a From: line.
7676
77+
--threaded Specify that the "In-Reply-To:" header should be set on all
78+
emails. Defaults to on.
79+
7780
--quiet Make git-send-email less verbose. One line per email
7881
should be all that is output.
7982
@@ -138,8 +141,8 @@ sub format_2822_time {
138141
$initial_reply_to,$initial_subject,@files,$from,$compose,$time);
139142

140143
# Behavior modification variables
141-
my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc,
142-
$dry_run) = (1, 0, 0, 0, 0);
144+
my ($threaded, $chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc,
145+
$dry_run) = (1, 1, 0, 0, 0, 0);
143146
my $smtp_server;
144147
my $envelope_sender;
145148

@@ -154,9 +157,16 @@ sub format_2822_time {
154157
$term = new FakeTerm "$@: going non-interactive";
155158
}
156159

157-
my $def_chain = $repo->config_bool('sendemail.chainreplyto');
158-
if (defined $def_chain and not $def_chain) {
159-
$chain_reply_to = 0;
160+
my %config_settings = (
161+
"threaded" => \$threaded,
162+
"chainreplyto" => \$chain_reply_to,
163+
);
164+
165+
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+
}
160170
}
161171

162172
@bcclist = $repo->config('sendemail.bcc');
@@ -181,6 +191,7 @@ sub format_2822_time {
181191
"no-signed-off-cc|no-signed-off-by-cc" => \$no_signed_off_cc,
182192
"dry-run" => \$dry_run,
183193
"envelope-sender=s" => \$envelope_sender,
194+
"threaded!" => \$threaded,
184195
);
185196

186197
unless ($rc) {
@@ -287,7 +298,7 @@ sub expand_aliases {
287298
$prompting++;
288299
}
289300

290-
if (!defined $initial_reply_to && $prompting) {
301+
if ($threaded && !defined $initial_reply_to && $prompting) {
291302
do {
292303
$_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ",
293304
$initial_reply_to);
@@ -484,7 +495,7 @@ sub send_message
484495
Message-Id: $message_id
485496
X-Mailer: git-send-email $gitversion
486497
";
487-
if ($reply_to) {
498+
if ($threaded && $reply_to) {
488499

489500
$header .= "In-Reply-To: $reply_to\n";
490501
$header .= "References: $references\n";

0 commit comments

Comments
 (0)