All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wesley Schwengle <wesleys@opperschaap.net>
To: git@vger.kernel.org
Subject: [PATCH] Fix bug when more than one readline instance is used
Date: Wed,  9 Aug 2023 20:39:33 -0400	[thread overview]
Message-ID: <20230810003939.1420306-1-wesleys@opperschaap.net> (raw)

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(-)

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"}
-- 
2.42.0.rc0.26.ga73c38ecaa


             reply	other threads:[~2023-08-10  0:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10  0:39 Wesley Schwengle [this message]
2023-08-10  0:49 ` [PATCH] Fix bug when more than one readline instance is used Jeff King
2023-08-10  1:18   ` [[PATCH v2]] " Wesley Schwengle
2023-08-10 14:31     ` Junio C Hamano
2023-08-10 15:14       ` Wesley
2023-08-11  1:01     ` Junio C Hamano
2023-08-11  1:09       ` Wesley
2023-08-11  5:30         ` Junio C Hamano
2023-08-11 14:51           ` Jeff King
2023-08-11 16:05             ` Junio C Hamano
2023-08-30 22:32               ` [PATCH] git-svn: drop FakeTerm hack Junio C Hamano
2023-08-31  0:13                 ` Jeff King
2023-08-31  0:28                   ` Junio C Hamano
2023-08-10  1:05 ` [PATCH] Fix bug when more than one readline instance is used Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230810003939.1420306-1-wesleys@opperschaap.net \
    --to=wesleys@opperschaap.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.