]> git.ipfire.org Git - thirdparty/git.git/commit - add-interactive.c
add -p: disable stdin buffering when interactive.singlekey is set
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Tue, 22 Feb 2022 18:53:35 +0000 (18:53 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Feb 2022 21:30:06 +0000 (13:30 -0800)
commitac618c418e5e16acd82dc3d8e4356a39150de5a2
tree8433f164f449ec2b7f9993a8f7bd9210552f30bc
parent2c6860211f211dfa5625dd1a5a69a802b4384dbb
add -p: disable stdin buffering when interactive.singlekey is set

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-interactive.c