Skip to content

Commit ad2a135

Browse files
peffdscho
authored andcommitted
send-email: drop FakeTerm hack
Back in 280242d (send-email: do not barf when Term::ReadLine does not like your terminal, 2006-07-02), we added a fallback for when Term::ReadLine's constructor failed: we'd have a FakeTerm object instead, which would then die if anybody actually tried to call readline() on it. Since we instantiated the $term variable at program startup, we needed this workaround to let the program run in modes when we did not prompt the user. But later, in f4dc943 (send-email: lazily load modules for a big speedup, 2021-05-28), we started loading Term::ReadLine lazily only when ask() is called. So at that point we know we're trying to prompt the user, and we can just die if ReadLine instantiation fails, rather than making this fake object to lazily delay showing the error. This should be OK even if there is no tty (e.g., we're in a cron job), because Term::ReadLine will return a stub object in that case whose "IN" and "OUT" functions return undef. And since 5906f54 (send-email: don't attempt to prompt if tty is closed, 2009-03-31), we check for that case and skip prompting. And we can be sure that FakeTerm was not kicking in for such a situation, because it has actually been broken since that commit! It does not define "IN" or "OUT" methods, so perl would barf with an error. If FakeTerm was in use, we were neither honoring what 5906f54 tried to do, nor producing the readable message that 280242d intended. So we're better off just dropping FakeTerm entirely, and letting the error reported by constructing Term::ReadLine through. Backported from dfd46ba (send-email: drop FakeTerm hack, 2023-08-08). Signed-off-by: Jeff King <peff@peff.net> Acked-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
1 parent 47b6d90 commit ad2a135

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

git-send-email.perl

Lines changed: 2 additions & 20 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>
@@ -930,16 +918,10 @@ sub get_patch_subject {
930918
}
931919
932920
sub term {
933-
my $term = eval {
934-
require Term::ReadLine;
935-
$ENV{"GIT_SEND_EMAIL_NOTTY"}
921+
require Term::ReadLine;
922+
return $ENV{"GIT_SEND_EMAIL_NOTTY"}
936923
? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT)
937924
: Term::ReadLine->new('git-send-email');
938-
};
939-
if ($@) {
940-
$term = FakeTerm->new("$@: going non-interactive");
941-
}
942-
return $term;
943925
}
944926
945927
sub ask {

0 commit comments

Comments
 (0)