git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Carlo Marcelo Arenas Belón" <carenas@gmail.com>,
	"Phillip Wood" <phillip.wood@dunelm.org.uk>,
	"Phillip Wood" <phillip.wood@dunelm.org.uk>
Subject: [PATCH v2 4/4] add -p: disable stdin buffering when interactive.singlekey is set
Date: Tue, 22 Feb 2022 18:53:35 +0000	[thread overview]
Message-ID: <39b061a471bb6e5306f94b3a6d7e19be6ed6a92f.1645556015.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1146.v2.git.1645556015.gitgitgadget@gmail.com>

From: Phillip Wood <phillip.wood@dunelm.org.uk>

The builtin "add -p" reads the key "F2" as three separate keys "^[",
"O" and "Q". The "Q" causes it to quit which is probably not what the
user was expecting. This is because it uses poll() to check for
pending input when reading escape sequences but reads the input with
getchar() which is buffered by default and so hoovers up all the
pending input leading poll() think there isn't anything pending. Fix
this by calling setbuf() to disable input buffering if
interactive.singlekey is set.

Looking at the comment above mingw_getchar() in terminal.c I wonder if
that function is papering over this bug and could be removed.
Unfortunately I don't have access to windows to test that.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 add-interactive.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/add-interactive.c b/add-interactive.c
index 6498ae196f1..ad78774ca26 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -70,6 +70,8 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
 			      &s->interactive_diff_algorithm);
 
 	git_config_get_bool("interactive.singlekey", &s->use_single_key);
+	if (s->use_single_key)
+		setbuf(stdin, NULL);
 }
 
 void clear_add_i_state(struct add_i_state *s)
-- 
gitgitgadget

  parent reply	other threads:[~2022-02-22 18:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 10:54 [PATCH 0/3] a couple of read_key_without_echo() fixes Phillip Wood via GitGitGadget
2022-02-16 10:54 ` [PATCH 1/3] terminal: pop signal handler when terminal is restored Phillip Wood via GitGitGadget
2022-02-16 10:54 ` [PATCH 2/3] terminal: set VMIN and VTIME in non-canonical mode Phillip Wood via GitGitGadget
2022-02-16 21:40   ` Junio C Hamano
2022-02-17 10:59     ` Phillip Wood
2022-02-16 10:54 ` [PATCH 3/3] add -p: disable stdin buffering when interactive.singlekey is set Phillip Wood via GitGitGadget
2022-02-16 21:43   ` Junio C Hamano
2022-02-22 18:53 ` [PATCH v2 0/4] a couple of read_key_without_echo() fixes Phillip Wood via GitGitGadget
2022-02-22 18:53   ` [PATCH v2 1/4] terminal: always reset terminal when reading without echo Phillip Wood via GitGitGadget
2022-02-22 18:53   ` [PATCH v2 2/4] terminal: pop signal handler when terminal is restored Phillip Wood via GitGitGadget
2022-02-22 18:53   ` [PATCH v2 3/4] terminal: set VMIN and VTIME in non-canonical mode Phillip Wood via GitGitGadget
2022-02-22 18:53   ` Phillip Wood via GitGitGadget [this message]
2022-02-23 21:34   ` [PATCH v2 0/4] a couple of read_key_without_echo() fixes Junio C Hamano
2022-02-24 14:30     ` Phillip Wood
2022-03-22 20:18       ` Carlo Arenas
2022-03-23  9:03         ` Junio C Hamano
2022-03-24 13:29           ` Johannes Schindelin
2022-03-28 10:51         ` Phillip Wood

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=39b061a471bb6e5306f94b3a6d7e19be6ed6a92f.1645556015.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).