@matheusbsbs / matheus-bagliano / commits / 0fb7fc751d
Fork 0

send-email: fix In-Reply-To regression

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>

Jay Soffian committed Feb 21, 2008 at 19:16 UTC 0fb7fc751d29cd1099556f71fc7c08158a6a78bc
2 files changed +27 -3
git-send-email.perl
+6 -3
@@ -170,7 +170,9 @@ my $envelope_sender;
170
171 my $repo = Git->repository();
172 my $term = eval {
173 - new Term::ReadLine 'git-send-email';
173 + $ENV{"GIT_SEND_EMAIL_NOTTY"}
174 + ? new Term::ReadLine 'git-send-email', \*STDIN, \*STDOUT
175 + : new Term::ReadLine 'git-send-email';
176 };
177 if ($@) {
178 $term = new FakeTerm "$@: going non-interactive";
@@ -476,8 +478,9 @@ if ($thread && !defined $initial_reply_to && $prompting) {
478 $initial_reply_to = $_;
479 }
480 if (defined $initial_reply_to) {
479 - $initial_reply_to =~ s/^\s*<?/</;
480 - $initial_reply_to =~ s/>?\s*$/>/;
481 + $initial_reply_to =~ s/^\s*<?//;
482 + $initial_reply_to =~ s/>?\s*$//;
483 + $initial_reply_to = "<$initial_reply_to>" if $initial_reply_to ne '';
484 }
485
486 if (!defined $smtp_server) {
t/t9001-send-email.sh
+21
@@ -108,4 +108,25 @@ test_expect_success 'allow long lines with --no-validate' '
108 2>errors
109 '
110
111 +test_expect_success 'Invalid In-Reply-To' '
112 + git send-email \
113 + --from="Example <nobody@example.com>" \
114 + --to=nobody@example.com \
115 + --in-reply-to=" " \
116 + --smtp-server="$(pwd)/fake.sendmail" \
117 + $patches
118 + 2>errors
119 + ! grep "^In-Reply-To: < *>" msgtxt
120 +'
121 +
122 +test_expect_success 'Valid In-Reply-To when prompting' '
123 + (echo "From Example <from@example.com>"
124 + echo "To Example <to@example.com>"
125 + echo ""
126 + ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
127 + --smtp-server="$(pwd)/fake.sendmail" \
128 + $patches 2>errors &&
129 + ! grep "^In-Reply-To: < *>" msgtxt
130 +'
131 +
132 test_done