public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Ensure restore_term works correctly with DUPLEX
@ 2025-06-17 18:56 James Duley via GitGitGadget
  2025-06-17 19:18 ` Junio C Hamano
  2025-06-23  9:35 ` Phillip Wood
  0 siblings, 2 replies; 7+ messages in thread
From: James Duley via GitGitGadget @ 2025-06-17 18:56 UTC (permalink / raw)
  To: git; +Cc: James Duley, James Duley

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

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
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-23  9:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox