From: Junio C Hamano <gitster@pobox.com>
To: "James Duley via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, "James Duley" <jagduley@gmail.com>,
"Carlo Marcelo Arenas Belón" <carenas@gmail.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] Ensure restore_term works correctly with DUPLEX
Date: Tue, 17 Jun 2025 12:18:07 -0700 [thread overview]
Message-ID: <xmqqh60euqhc.fsf@gitster.g> (raw)
In-Reply-To: <pull.2000.git.git.1750186571037.gitgitgadget@gmail.com> (James Duley via GitGitGadget's message of "Tue, 17 Jun 2025 18:56:10 +0000")
"James Duley via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: James Duley <jagduley@gmail.com>
>
> Previously, if save_term/restore_term was called with the DUPLEX flag
> and then without the flag, an assertion was hit.
>> Assertion failed: hconout != INVALID_HANDLE_VALUE,
>> file compat/terminal.c, line 283
>
> This is because save_term doesn't set cmode_out when not DUPLEX,
> so an old version of cmode_out was being used.
> Therefore, hconout is the correct thing for restore to check
> to decide whether to restore stdout console mode.
>
> I saw this on Windows with interactive.singleKey when doing `git add -p`.
> Specifically, after hitting `e` to edit in vim, once on to the prompt
> for the next hunk, pressing any key results in the assertion.
>
> Signed-off-by: James Duley <jagduley@gmail.com>
> ---
> Ensure restore_term works correctly with DUPLEX
Ran "git log -L247,290:compat/terminal.c" to find commits that
touched this Windows specific area of the code to see who might be
capable of reviewing this change, as I am certainly not one of them.
e22b245e (terminal: teach git how to save/restore its terminal
settings, 2021-10-05) is where the assert being removed came from,
it seems.
The author of that commit should be CC'ed if we want to ask for a
quicker review. I'll also add Git-for-Windows maintainer as well.
Thanks.
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2000%2Fparched%2Frestore-term-windows-fix-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2000/parched/restore-term-windows-fix-v1
> Pull-Request: https://github.com/git/git/pull/2000
>
> compat/terminal.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/compat/terminal.c b/compat/terminal.c
> index 584f27bf7e1..72b184555ff 100644
> --- a/compat/terminal.c
> +++ b/compat/terminal.c
> @@ -279,8 +279,7 @@ void restore_term(void)
>
> SetConsoleMode(hconin, cmode_in);
> CloseHandle(hconin);
> - if (cmode_out) {
> - assert(hconout != INVALID_HANDLE_VALUE);
> + if (hconout != INVALID_HANDLE_VALUE) {
> SetConsoleMode(hconout, cmode_out);
> CloseHandle(hconout);
> }
>
> base-commit: 16bd9f20a403117f2e0d9bcda6c6e621d3763e77
next prev parent reply other threads:[~2025-06-17 19:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 18:56 [PATCH] Ensure restore_term works correctly with DUPLEX James Duley via GitGitGadget
2025-06-17 19:18 ` Junio C Hamano [this message]
2025-06-18 10:07 ` Carlo Marcelo Arenas Belón
2025-06-18 20:38 ` James Duley
2025-06-18 23:43 ` Carlo Marcelo Arenas Belón
2025-06-23 9:42 ` Phillip Wood
2025-06-23 9:35 ` 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=xmqqh60euqhc.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=carenas@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=jagduley@gmail.com \
/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