Skip to content

Commit fc71d02

Browse files
committed
Merge branch 'jk/send-email-with-new-readline'
Adjust to newer Term::ReadLine to prevent it from breaking the interactive prompt code in send-email. * jk/send-email-with-new-readline: send-email: avoid creating more than one Term::ReadLine object send-email: drop FakeTerm hack
2 parents 6df312a + c016726 commit fc71d02

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

git-send-email.perl

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@
2626

2727
Getopt::Long::Configure qw/ pass_through /;
2828

29-
package FakeTerm;
30-
sub new {
31-
my ($class, $reason) = @_;
32-
return bless \$reason, shift;
33-
}
34-
sub readline {
35-
my $self = shift;
36-
die "Cannot use readline on FakeTerm: $$self";
37-
}
38-
package main;
39-
40-
4129
sub usage {
4230
print <<EOT;
4331
git send-email' [<options>] <file|directory>
@@ -971,17 +959,19 @@ sub get_patch_subject {
971959
do_edit(@files);
972960
}
973961
974-
sub term {
975-
my $term = eval {
962+
{
963+
# Only instantiate one $term per program run, since some
964+
# Term::ReadLine providers refuse to create a second instance.
965+
my $term;
966+
sub term {
976967
require Term::ReadLine;
977-
$ENV{"GIT_SEND_EMAIL_NOTTY"}
978-
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
979-
: Term::ReadLine->new('git-send-email');
980-
};
981-
if ($@) {
982-
$term = FakeTerm->new("$@: going non-interactive");
968+
if (!defined $term) {
969+
$term = $ENV{"GIT_SEND_EMAIL_NOTTY"}
970+
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
971+
: Term::ReadLine->new('git-send-email');
972+
}
973+
return $term;
983974
}
984-
return $term;
985975
}
986976
987977
sub ask {

t/t9001-send-email.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,14 @@ test_expect_success $PREREQ 'Show all headers' '
337337
test_expect_success $PREREQ 'Prompting works' '
338338
clean_fake_sendmail &&
339339
(echo "[email protected]" &&
340-
echo ""
340+
341341
) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
342342
--smtp-server="$(pwd)/fake.sendmail" \
343343
$patches \
344344
2>errors &&
345345
grep "^From: A U Thor <[email protected]>\$" msgtxt1 &&
346-
grep "^To: [email protected]\$" msgtxt1
346+
grep "^To: [email protected]\$" msgtxt1 &&
347+
grep "^In-Reply-To: <[email protected]>" msgtxt1
347348
'
348349

349350
test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' '

0 commit comments

Comments
 (0)