summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2022-02-22 18:53:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-02-23 21:30:06 (GMT)
commit2c6860211f211dfa5625dd1a5a69a802b4384dbb (patch)
treeef88ebfabe8a26531f77664529082014a467b5b5 /compat
parentf7da756566e8abf18abdf9e30a8ed6d2088770de (diff)
downloadgit-2c6860211f211dfa5625dd1a5a69a802b4384dbb.zip
git-2c6860211f211dfa5625dd1a5a69a802b4384dbb.tar.gz
git-2c6860211f211dfa5625dd1a5a69a802b4384dbb.tar.bz2
terminal: set VMIN and VTIME in non-canonical mode
If VMIN and VTIME are both set to zero then the terminal performs non-blocking reads which means that read_key_without_echo() returns EOF if there is no key press pending. This results in the user being unable to select anything when running "git add -p". Fix this by explicitly setting VMIN and VTIME when enabling non-canonical mode. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat')
-rw-r--r--compat/terminal.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/compat/terminal.c b/compat/terminal.c
index 11288cf..3620184 100644
--- a/compat/terminal.c
+++ b/compat/terminal.c
@@ -57,6 +57,10 @@ static int disable_bits(tcflag_t bits)
t = old_term;
t.c_lflag &= ~bits;
+ if (bits & ICANON) {
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
+ }
if (!tcsetattr(term_fd, TCSAFLUSH, &t))
return 0;
@@ -159,7 +163,11 @@ static int disable_bits(DWORD bits)
if (bits & ENABLE_LINE_INPUT) {
string_list_append(&stty_restore, "icanon");
- strvec_push(&cp.args, "-icanon");
+ /*
+ * POSIX allows VMIN and VTIME to overlap with VEOF and
+ * VEOL - let's hope that is not the case on windows.
+ */
+ strvec_pushl(&cp.args, "-icanon", "min", "1", "time", "0", NULL);
}
if (bits & ENABLE_ECHO_INPUT) {