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
maint
Junio C Hamano 2023-08-14 13:26:41 -07:00
commit fc71d024ad
2 changed files with 14 additions and 23 deletions

View File

@ -26,18 +26,6 @@ use Git::I18N;

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

package FakeTerm;
sub new {
my ($class, $reason) = @_;
return bless \$reason, shift;
}
sub readline {
my $self = shift;
die "Cannot use readline on FakeTerm: $$self";
}
package main;


sub usage {
print <<EOT;
git send-email' [<options>] <file|directory>
@ -971,17 +959,19 @@ EOT3
do_edit(@files);
}

sub term {
my $term = eval {
{
# Only instantiate one $term per program run, since some
# Term::ReadLine providers refuse to create a second instance.
my $term;
sub term {
require Term::ReadLine;
$ENV{"GIT_SEND_EMAIL_NOTTY"}
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
: Term::ReadLine->new('git-send-email');
};
if ($@) {
$term = FakeTerm->new("$@: going non-interactive");
if (!defined $term) {
$term = $ENV{"GIT_SEND_EMAIL_NOTTY"}
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
: Term::ReadLine->new('git-send-email');
}
return $term;
}
return $term;
}

sub ask {

View File

@ -337,13 +337,14 @@ test_expect_success $PREREQ 'Show all headers' '
test_expect_success $PREREQ 'Prompting works' '
clean_fake_sendmail &&
(echo "to@example.com" &&
echo ""
echo "my-message-id@example.com"
) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
--smtp-server="$(pwd)/fake.sendmail" \
$patches \
2>errors &&
grep "^From: A U Thor <author@example.com>\$" msgtxt1 &&
grep "^To: to@example.com\$" msgtxt1
grep "^To: to@example.com\$" msgtxt1 &&
grep "^In-Reply-To: <my-message-id@example.com>" msgtxt1
'

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