Skip to content

Commit a055c1b

Browse files
gitsterdscho
authored andcommitted
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 This is a backport of fc71d02 (Merge branch 'jk/send-email-with-new-readline', 2023-08-14).
2 parents 47b6d90 + 4791fc0 commit a055c1b

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>
@@ -929,17 +917,19 @@ sub get_patch_subject {
929917
do_edit(@files);
930918
}
931919
932-
sub term {
933-
my $term = eval {
920+
{
921+
# Only instantiate one $term per program run, since some
922+
# Term::ReadLine providers refuse to create a second instance.
923+
my $term;
924+
sub term {
934925
require Term::ReadLine;
935-
$ENV{"GIT_SEND_EMAIL_NOTTY"}
936-
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
937-
: Term::ReadLine->new('git-send-email');
938-
};
939-
if ($@) {
940-
$term = FakeTerm->new("$@: going non-interactive");
926+
if (!defined $term) {
927+
$term = $ENV{"GIT_SEND_EMAIL_NOTTY"}
928+
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
929+
: Term::ReadLine->new('git-send-email');
930+
}
931+
return $term;
941932
}
942-
return $term;
943933
}
944934
945935
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 "to@example.com" &&
340-
echo ""
340+
echo "my-message-id@example.com"
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 <author@example.com>\$" msgtxt1 &&
346-
grep "^To: to@example.com\$" msgtxt1
346+
grep "^To: to@example.com\$" msgtxt1 &&
347+
grep "^In-Reply-To: <my-message-id@example.com>" msgtxt1
347348
'
348349

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

0 commit comments

Comments
 (0)