Skip to content

Commit

Permalink
prepare send-email for smoother change of --chain-reply-to default
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nanako Shiraishi authored and Junio C Hamano committed Nov 29, 2009
1 parent 66abce0 commit 528fb08
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
19 changes: 17 additions & 2 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@ sub do_edit {
my ($validate, $confirm);
my (@suppress_cc);

my $not_set_by_user = "true but not set by the user";

my %config_bool_settings = (
"thread" => [\$thread, 1],
"chainreplyto" => [\$chain_reply_to, 1],
"chainreplyto" => [\$chain_reply_to, $not_set_by_user],
"suppressfrom" => [\$suppress_from, undef],
"signedoffbycc" => [\$signed_off_by_cc, undef],
"signedoffcc" => [\$signed_off_by_cc, undef], # Deprecated
Expand All @@ -214,6 +216,19 @@ sub do_edit {
"from" => \$sender,
);

# Help users prepare for 1.7.0
sub chain_reply_to {
if (defined $chain_reply_to &&
$chain_reply_to eq $not_set_by_user) {
print STDERR
"In git 1.7.0, the default will be changed to --no-chain-reply-to\n" .
"Set sendemail.chainreplyto configuration variable to true if\n" .
"you want to keep --chain-reply-to as your default.\n";
$chain_reply_to = 1;
}
return $chain_reply_to;
}

# Handle Uncouth Termination
sub signal_handler {

Expand Down Expand Up @@ -1157,7 +1172,7 @@ sub send_message

# set up for the next message
if ($thread && $message_was_sent &&
($chain_reply_to || !defined $reply_to || length($reply_to) == 0)) {
(chain_reply_to() || !defined $reply_to || length($reply_to) == 0)) {
$reply_to = $message_id;
if (length $references > 0) {
$references .= "\n $message_id";
Expand Down
49 changes: 49 additions & 0 deletions t/t9001-send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -769,4 +769,53 @@ test_expect_success 'threading but no chain-reply-to' '
grep "In-Reply-To: " stdout
'

test_expect_success 'warning with an implicit --chain-reply-to' '
git send-email \
--dry-run \
--from="Example <nobody@example.com>" \
--to=nobody@example.com \
outdir/000?-*.patch 2>errors >out &&
grep "no-chain-reply-to" errors
'

test_expect_success 'no warning with an explicit --chain-reply-to' '
git send-email \
--dry-run \
--from="Example <nobody@example.com>" \
--to=nobody@example.com \
--chain-reply-to \
outdir/000?-*.patch 2>errors >out &&
! grep "no-chain-reply-to" errors
'

test_expect_success 'no warning with an explicit --no-chain-reply-to' '
git send-email \
--dry-run \
--from="Example <nobody@example.com>" \
--to=nobody@example.com \
--no-chain-reply-to \
outdir/000?-*.patch 2>errors >out &&
! grep "no-chain-reply-to" errors
'

test_expect_success 'no warning with sendemail.chainreplyto = false' '
git config sendemail.chainreplyto false &&
git send-email \
--dry-run \
--from="Example <nobody@example.com>" \
--to=nobody@example.com \
outdir/000?-*.patch 2>errors >out &&
! grep "no-chain-reply-to" errors
'

test_expect_success 'no warning with sendemail.chainreplyto = true' '
git config sendemail.chainreplyto true &&
git send-email \
--dry-run \
--from="Example <nobody@example.com>" \
--to=nobody@example.com \
outdir/000?-*.patch 2>errors >out &&
! grep "no-chain-reply-to" errors
'

test_done

0 comments on commit 528fb08

Please sign in to comment.