Message ID | 20230810003939.1420306-1-wesleys@opperschaap.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix bug when more than one readline instance is used | expand |
On Wed, Aug 09, 2023 at 08:39:33PM -0400, Wesley Schwengle wrote: > The following error was emitted if one issued the command > > git send-email --compose 0001-my.patch > > Can't locate object method "IN" via package "FakeTerm" at > /home/wesleys/libexec/git-core/git-send-email line 997. > > After added a warn in the relevant function that created the term it was > obvious what happened: > > Only one Term::ReadLine::Gnu instance is allowed. at > /home/wesleys/libexec/git-core/git-send-email line 981. I posted a similar fix yesterday, which is currently in 'next' via d42e4ca9f8: https://lore.kernel.org/git/20230808180935.GA2096901@coredump.intra.peff.net/ However... > More or less the same logic happens in git-svn.perl so I fixed it there > as well. ...I didn't touch git-svn.perl, and I agree it probably has the same problem (I didn't try it in practice, but any time ask() is called twice it will run into the same issue). Do you want to prepare a patch on top removing the git-svn bits (probably all of FakeTerm, too)? -Peff
Wesley Schwengle <wesleys@opperschaap.net> writes: If I recall correctly, this was fixed by Peff yesterday? https://lore.kernel.org/git/20230808181531.GB2097200@coredump.intra.peff.net/ > diff --git a/git-send-email.perl b/git-send-email.perl > index affbb88509..7fdcf9084a 100755 > --- a/git-send-email.perl > +++ b/git-send-email.perl > @@ -971,8 +971,10 @@ sub get_patch_subject { > do_edit(@files); > } > > +my $term; > sub term { > - my $term = eval { > + return $term if $term; > + $term = eval { > require Term::ReadLine; > $ENV{"GIT_SEND_EMAIL_NOTTY"} > ? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT) The patch I queued yesterday wraps this lexical inside another block to hide it from the outside, but otherwise it should achieve the same goal.
diff --git a/git-send-email.perl b/git-send-email.perl index affbb88509..7fdcf9084a 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -971,8 +971,10 @@ sub get_patch_subject { do_edit(@files); } +my $term; sub term { - my $term = eval { + return $term if $term; + $term = eval { require Term::ReadLine; $ENV{"GIT_SEND_EMAIL_NOTTY"} ? Term::ReadLine->new('git-send-email', \*STDIN, \*STDOUT) diff --git a/git-svn.perl b/git-svn.perl index be987e316f..2813551e06 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -306,10 +306,12 @@ sub readline { my $self = shift; die "Cannot use readline on FakeTerm: $$self"; } + package main; my $term; sub term_init { + return $term if $term; $term = eval { require Term::ReadLine; $ENV{"GIT_SVN_NOTTY"}
The following error was emitted if one issued the command git send-email --compose 0001-my.patch Can't locate object method "IN" via package "FakeTerm" at /home/wesleys/libexec/git-core/git-send-email line 997. After added a warn in the relevant function that created the term it was obvious what happened: Only one Term::ReadLine::Gnu instance is allowed. at /home/wesleys/libexec/git-core/git-send-email line 981. When you supply no --to send-email asks you to whom you want to send the email to. This starts a term, the first Term::ReadLine::Gnu instance. The second time it wants to ask the user 'Send this email? ([y]es|[n]o|[e]dit|[q]uit|[a]ll):' and this causes FakeTerm to be loaded, but it doesn't have IN/OUT methods and thus fails. The fix is to make $term global. If git chooses to drop perl 5.8 support and allows Perl 5.10, we could also use the state feature. Which would solve the problem without making $term global. More or less the same logic happens in git-svn.perl so I fixed it there as well. Signed-off-by: Wesley Schwengle <wesleys@opperschaap.net> --- git-send-email.perl | 4 +++- git-svn.perl | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)