Skip to content

Commit

Permalink
send-email: fix In-Reply-To regression
Browse files Browse the repository at this point in the history
Fix a regression introduced by

1ca3d6e (send-email: squelch warning due to comparing undefined $_ to "")

where if the user was prompted for an initial In-Reply-To and didn't
provide one, messages would be sent out with an invalid In-Reply-To of
"<>"

Also add test cases for the regression and the fix. A small modification
was needed to allow send-email to take its replies from stdin if the
environment variable GIT_SEND_EMAIL_NOTTY is set.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jay Soffian authored and Junio C Hamano committed Feb 27, 2008
1 parent 12f0a5e commit 6ecbc85
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
9 changes: 6 additions & 3 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ sub format_2822_time {

my $repo = Git->repository();
my $term = eval {
new Term::ReadLine 'git-send-email';
$ENV{"GIT_SEND_EMAIL_NOTTY"}
? new Term::ReadLine 'git-send-email', \*STDIN, \*STDOUT
: new Term::ReadLine 'git-send-email';
};
if ($@) {
$term = new FakeTerm "$@: going non-interactive";
Expand Down Expand Up @@ -407,8 +409,9 @@ sub expand_aliases {
$initial_reply_to = $_;
}
if (defined $initial_reply_to) {
$initial_reply_to =~ s/^\s*<?/</;
$initial_reply_to =~ s/>?\s*$/>/;
$initial_reply_to =~ s/^\s*<?//;
$initial_reply_to =~ s/>?\s*$//;
$initial_reply_to = "<$initial_reply_to>" if $initial_reply_to ne '';
}

if (!defined $smtp_server) {
Expand Down
21 changes: 21 additions & 0 deletions t/t9001-send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,25 @@ test_expect_success 'allow long lines with --no-validate' '
2>errors
'

test_expect_success 'Invalid In-Reply-To' '
git send-email \
--from="Example <nobody@example.com>" \
--to=nobody@example.com \
--in-reply-to=" " \
--smtp-server="$(pwd)/fake.sendmail" \
$patches
2>errors
! grep "^In-Reply-To: < *>" msgtxt
'

test_expect_success 'Valid In-Reply-To when prompting' '
(echo "From Example <from@example.com>"
echo "To Example <to@example.com>"
echo ""
) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
--smtp-server="$(pwd)/fake.sendmail" \
$patches 2>errors &&
! grep "^In-Reply-To: < *>" msgtxt
'

test_done

0 comments on commit 6ecbc85

Please sign in to comment.