-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git hooks can corrupt command line on Windows #730
Git hooks can corrupt command line on Windows #730
Comments
Unfortunately, there was a rather big MSYS2 runtime version jump between .0.2 and .0.3: -msys2-runtime 3.5.4-5
+msys2-runtime 3.5.7-1 Just to be sure, could you download v3.5.4-5 of |
I swapped out the dll and that did fix the regression. It does look like that dependency upgrade is what introduced the problem. |
@marcelais thank you for confirming, and thank you for jumping into the private chat with me. I think I got a pretty reliable reproducer:
What I observe is that the What I suspect is happening is that Cygwin assumes full control over some Console state that it wants to temporarily switch while the (MINGW) Even if that suspicion is wrong: There is something highly iffy going on, messing up Console state like that, from which you can only recover by force-terminating the interactive Bash. Since this reproduces with the regular Cygwin runtime (and not only with the friendly fork thereof that is the MSYS2 runtime that Git for Windows and |
The required console mode for a non-cygwin process is different from that for a cygwin process. There are currently three modes: tty::cygwin, tty::native, and tty::restore. The latter two are for the non-cygwin processes. tty::restore is the mode for the non-cygwin processes that started the cygwin process, used to restore the previous behaviour. tty::native is the mode that reflects some terminfo flags. The issue below is caused because the console mode fails to be restored to the previous console mode used by cmd.exe. This patch redesigns the strategy to determine which mode should be set on console close() to fix all similar problems. Previously, the number of handle count is used to determine the appropriate console mode. However, the handle count seems uncertain for that purpose. In the new design, the relation ship between the master process and the process that is about to close the console is mainly used. This can provide more certain result than previous one. Addresses: microsoft/git#730 Fixes: 30d2669 ("Cygwin: console: Fix clean up conditions in close()") Reported-by: Mike Marcelais, Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
The required console mode for a non-cygwin process is different from that for a cygwin process. There are currently three modes: tty::cygwin, tty::native, and tty::restore. The latter two are for the non-cygwin processes. tty::restore is the mode for the non-cygwin processes that started the cygwin process, used to restore the previous behaviour. tty::native is the mode that reflects some terminfo flags. The issue below is caused because the console mode fails to be restored to the previous console mode used by cmd.exe. This patch redesigns the strategy to determine which mode should be set on console close() to fix all similar problems. Previously, the number of handle count is used to determine the appropriate console mode. However, the handle count seems uncertain for that purpose. In the new design, the relation ship between the master process and the process that is about to close the console is mainly used. This can provide more certain result than previous one. Addresses: microsoft/git#730 Backported-from: 3312f2d21f (Cygwin: console: Redesign mode set strategy on close()., 2025-03-03) Fixes: 30d2669 ("Cygwin: console: Fix clean up conditions in close()") Reported-by: Mike Marcelais, Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@marcelais could I ask you to download the |
The required console mode for a non-cygwin process is different from that for a cygwin process. There are currently three modes: tty::cygwin, tty::native, and tty::restore. The latter two are for the non-cygwin processes. tty::restore is the mode for the non-cygwin processes that started the cygwin process, used to restore the previous behaviour. tty::native is the mode that reflects some terminfo flags. The issue below is caused because the console mode fails to be restored to the previous console mode used by cmd.exe. This patch redesigns the strategy to determine which mode should be set on console close() to fix all similar problems. Previously, the number of handle count is used to determine the appropriate console mode. However, the handle count seems uncertain for that purpose. In the new design, the relation ship between the master process and the process that is about to close the console is mainly used. This can provide more certain result than previous one. Addresses: microsoft/git#730 Backported-from: 3312f2d (Cygwin: console: Redesign mode set strategy on close()., 2025-03-03) Fixes: 30d2669 ("Cygwin: console: Fix clean up conditions in close()") Reported-by: Mike Marcelais, Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Yes, this fixes the problem in our real hooks as well. |
On Windows, if you have a git hook which spawns a background process (in our case, to report telemetry for the tool asynchronously), after running a Git command, the cmd command prompt is "corrupted" in that control keys like ESC and up/down arrow no longer are interpreted correctly but instead result in ^[ or ^[[A being displayed.
Running "chcp" restores the correct behavior of the command prompt.
This is a regression in v2.47.2.vfs.0.3. This version (and newer) show the bad behavior while v2.47.2.vfs.0.2 (and earlier) work properly.
The text was updated successfully, but these errors were encountered: