aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Soffian <jaysoffian@gmail.com>2008-02-21 19:16:04 -0500
committerJunio C Hamano <gitster@pobox.com>2008-02-27 13:26:14 -0800
commit6ecbc851fb30f540e1a25761f221aab963cfe619 (patch)
treefc87cd6022a99fdabd0d3dedbcadda98796f3142
parent12f0a5ea7dc999bfe06973bf61261fc809c2b2fb (diff)
downloadgit-6ecbc851fb30f540e1a25761f221aab963cfe619.tar.gz
git-6ecbc851fb30f540e1a25761f221aab963cfe619.tar.xz
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>
-rwxr-xr-xgit-send-email.perl9
-rwxr-xr-xt/t9001-send-email.sh21
2 files changed, 27 insertions, 3 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 8e6f3b22c..e5d67f1b6 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -166,7 +166,9 @@ my $envelope_sender;
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";
@@ -407,8 +409,9 @@ if ($thread && !defined $initial_reply_to && $prompting) {
$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) {
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 08f7c3d8d..2efaed441 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -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