Subject: Re: [PATCH v2 0/4] builtin add -p: hopefully final readkey fixes

From: Junio C Hamano <[email-masked]>
Date: Wed, 09 Mar 2022 15:37:17 -0800

Junio C Hamano <[email-masked]> writes:

>> These patches are based on 'pw/single-key-interactive'
>
> Is it still true, or does the base only apply to v1?
>
> $ git checkout --detach pw/single-key-interactive
> HEAD is now at ac618c418e add -p: disable stdin buffering when interactive.singlekey is set
> $ git am -s ./+pw4-v2-add-p-single
> Applying: terminal: use flags for save_term()
> Applying: terminal: don't assume stdin is /dev/tty
> Applying: terminal: work around macos poll() bug
> error: patch failed: compat/terminal.c:397
> error: compat/terminal.c: patch does not apply
> Patch failed at 0003 terminal: work around macos poll() bug
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".
> $ exit

I think I figured it out.  A merge of pw/single-key-interactive into
a recent tip of 'master' wants the "return 0" in the preimage below
to be "break" in compat/terminal.c

> @@ -397,12 +433,7 @@ int read_key_without_echo(struct strbuf *buf)
>  		 * half a second when we know that the sequence is complete.
>  		 */
>  		while (!is_known_escape_sequence(buf->buf)) {
> -			struct pollfd pfd = { .fd = 0, .events = POLLIN };
> -
> -			if (poll(&pfd, 1, 500) < 1)
> -				break;
> -
> -			ch = getchar();
> +			ch = getchar_with_timeout(500);
>  			if (ch == EOF)
>  				return 0;
>  			strbuf_addch(buf, ch);

I'll wiggle it in to see how well it fares with other topics in
flight.

Thanks.