prepare send-email for smoother change of --chain-reply-to default
Give a warning message when send-email uses chain-reply-to to thread the messages because of the current default, not because the user explicitly asked to, either from the command line or from the configuration. This way, by the time 1.7.0 switches the default, everybody will be ready. Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nanako Shiraishi committed
Nov 29, 2009 at 12:24 UTC
528fb08732aa742edf56bc61cc8943c7f6d02977
2 files changed
+66
-2
git-send-email.perl
+17
-2
@@ -187,9 +187,11 @@ my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
187
my ($validate, $confirm);
188
my (@suppress_cc);
189
190
+my $not_set_by_user = "true but not set by the user";
191
+
192
my %config_bool_settings = (
193
"thread" => [\$thread, 1],
192
- "chainreplyto" => [\$chain_reply_to, 1],
194
+ "chainreplyto" => [\$chain_reply_to, $not_set_by_user],
195
"suppressfrom" => [\$suppress_from, undef],
196
"signedoffbycc" => [\$signed_off_by_cc, undef],
197
"signedoffcc" => [\$signed_off_by_cc, undef], # Deprecated
@@ -214,6 +216,19 @@ my %config_settings = (
216
"from" => \$sender,
217
);
218
219
+# Help users prepare for 1.7.0
220
+sub chain_reply_to {
221
+ if (defined $chain_reply_to &&
222
+ $chain_reply_to eq $not_set_by_user) {
223
+ print STDERR
224
+ "In git 1.7.0, the default will be changed to --no-chain-reply-to\n" .
225
+ "Set sendemail.chainreplyto configuration variable to true if\n" .
226
+ "you want to keep --chain-reply-to as your default.\n";
227
+ $chain_reply_to = 1;
228
+ }
229
+ return $chain_reply_to;
230
+}
231
+
232
# Handle Uncouth Termination
233
sub signal_handler {
234
@@ -1157,7 +1172,7 @@ foreach my $t (@files) {
1172
1173
# set up for the next message
1174
if ($thread && $message_was_sent &&
1160
- ($chain_reply_to || !defined $reply_to || length($reply_to) == 0)) {
1175
+ (chain_reply_to() || !defined $reply_to || length($reply_to) == 0)) {
1176
$reply_to = $message_id;
1177
if (length $references > 0) {
1178
$references .= "\n $message_id";
t/t9001-send-email.sh
+49
@@ -769,4 +769,53 @@ test_expect_success 'threading but no chain-reply-to' '
769
grep "In-Reply-To: " stdout
770
'
771
772
+test_expect_success 'warning with an implicit --chain-reply-to' '
773
+ git send-email \
774
+ --dry-run \
775
+ --from="Example <nobody@example.com>" \
776
+ --to=nobody@example.com \
777
+ outdir/000?-*.patch 2>errors >out &&
778
+ grep "no-chain-reply-to" errors
779
+'
780
+
781
+test_expect_success 'no warning with an explicit --chain-reply-to' '
782
+ git send-email \
783
+ --dry-run \
784
+ --from="Example <nobody@example.com>" \
785
+ --to=nobody@example.com \
786
+ --chain-reply-to \
787
+ outdir/000?-*.patch 2>errors >out &&
788
+ ! grep "no-chain-reply-to" errors
789
+'
790
+
791
+test_expect_success 'no warning with an explicit --no-chain-reply-to' '
792
+ git send-email \
793
+ --dry-run \
794
+ --from="Example <nobody@example.com>" \
795
+ --to=nobody@example.com \
796
+ --no-chain-reply-to \
797
+ outdir/000?-*.patch 2>errors >out &&
798
+ ! grep "no-chain-reply-to" errors
799
+'
800
+
801
+test_expect_success 'no warning with sendemail.chainreplyto = false' '
802
+ git config sendemail.chainreplyto false &&
803
+ git send-email \
804
+ --dry-run \
805
+ --from="Example <nobody@example.com>" \
806
+ --to=nobody@example.com \
807
+ outdir/000?-*.patch 2>errors >out &&
808
+ ! grep "no-chain-reply-to" errors
809
+'
810
+
811
+test_expect_success 'no warning with sendemail.chainreplyto = true' '
812
+ git config sendemail.chainreplyto true &&
813
+ git send-email \
814
+ --dry-run \
815
+ --from="Example <nobody@example.com>" \
816
+ --to=nobody@example.com \
817
+ outdir/000?-*.patch 2>errors >out &&
818
+ ! grep "no-chain-reply-to" errors
819
+'
820
+
821
test_done