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
6ecbc851fb30f540e1a25761f221aab963cfe619
2 files changed
+27
-3
git-send-email.perl
+6
-3
@@ -166,7 +166,9 @@ my $envelope_sender;
166
167
my $repo = Git->repository();
168
my $term = eval {
169
- new Term::ReadLine 'git-send-email';
169
+ $ENV{"GIT_SEND_EMAIL_NOTTY"}
170
+ ? new Term::ReadLine 'git-send-email', \*STDIN, \*STDOUT
171
+ : new Term::ReadLine 'git-send-email';
172
};
173
if ($@) {
174
$term = new FakeTerm "$@: going non-interactive";
@@ -407,8 +409,9 @@ if ($thread && !defined $initial_reply_to && $prompting) {
409
$initial_reply_to = $_;
410
}
411
if (defined $initial_reply_to) {
410
- $initial_reply_to =~ s/^\s*<?/</;
411
- $initial_reply_to =~ s/>?\s*$/>/;
412
+ $initial_reply_to =~ s/^\s*<?//;
413
+ $initial_reply_to =~ s/>?\s*$//;
414
+ $initial_reply_to = "<$initial_reply_to>" if $initial_reply_to ne '';
415
}
416
417
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