Skip to content

Commit 5dd61fa

Browse files
committed
msys2-runtime: update to 3.6.1-3
Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b160d8e commit 5dd61fa

5 files changed

+373
-6
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 28176974e765b6aa37def4141d47637c50d75aad Mon Sep 17 00:00:00 2001
2+
From: Takashi Yano <[email protected]>
3+
Date: Fri, 11 Apr 2025 20:03:11 +0900
4+
Subject: [PATCH 50/N] newlib: sys/unistd.h: Change inline to __inline
5+
6+
Addresses: https://sourceware.org/pipermail/cygwin-patches/2025q2/013644.html
7+
Fixes: 3e8a7eb1a868 ("sys/unistd.h: fix definition of setproctitle_init")
8+
Reported-by: Brian Inglis <[email protected]>
9+
Co-authored-by: Corinna Vinschen <[email protected]>
10+
Signed-off-by: Takashi Yano <[email protected]>
11+
(cherry picked from commit 1c530c37fd637ab1b7607b810d0495570932b8e7)
12+
---
13+
newlib/libc/include/sys/unistd.h | 2 +-
14+
1 file changed, 1 insertion(+), 1 deletion(-)
15+
16+
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
17+
index 771a4bd..4cf9f06 100644
18+
--- a/newlib/libc/include/sys/unistd.h
19+
+++ b/newlib/libc/include/sys/unistd.h
20+
@@ -215,7 +215,7 @@ int setpgrp (void);
21+
#if defined(__CYGWIN__) && __BSD_VISIBLE
22+
/* Stub for Linux libbsd compatibility. */
23+
#define initsetproctitle(c, a, e) setproctitle_init((c), (a), (e))
24+
-static inline void setproctitle_init (int _c, char *_a[], char *_e[]) {}
25+
+static __inline void setproctitle_init (int _c, char *_a[], char *_e[]) {}
26+
27+
void setproctitle (const char *, ...)
28+
_ATTRIBUTE ((__format__ (__printf__, 1, 2)));
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
From a86d33ef296849d7ef2e954e1f296236d2c2a5c3 Mon Sep 17 00:00:00 2001
2+
From: Takashi Yano <[email protected]>
3+
Date: Wed, 7 May 2025 15:40:22 +0900
4+
Subject: [PATCH 51/N] Cygwin: console: Store console mode only when console
5+
is opened
6+
7+
... and restore it when app exits. The commit 0bfd91d57863 has a bug
8+
that the console mode is stored into the shared memory when both:
9+
(1) cygwin process is started from non-cygwin process.
10+
(2) cygwin process started from non-cygwin process exits.
11+
(1) is intended, but (2) is not. Due to (2), the stored console mode
12+
is unexpectedly broken when the cygwin process exits. Then the mode
13+
restored will be not as expected. This causes undesired console mode
14+
in the use case that cygwin and non-cygwin apps are mixed.
15+
16+
With this patch, the console mode will stored only in the case (1).
17+
This is done by putting the code, which stores the console mode, into
18+
fhandler_console::open() rather than fhandler_console::set_input_mode()
19+
and fhandler_console::set_output_mode().
20+
21+
Fixes: 0bfd91d57863 ("Cygwin: console: tty::restore really restores the previous mode")
22+
Reported-by: Johannes Schindelin <[email protected]>
23+
Signed-off-by: Takashi Yano <[email protected]>
24+
(cherry picked from commit 09ae9f6ee99e2b58dcb17af563f15e8026b773ae)
25+
---
26+
winsup/cygwin/fhandler/console.cc | 33 ++++++++++++++++++++-----------
27+
1 file changed, 22 insertions(+), 11 deletions(-)
28+
29+
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
30+
index f33e354..2a224fe 100644
31+
--- a/winsup/cygwin/fhandler/console.cc
32+
+++ b/winsup/cygwin/fhandler/console.cc
33+
@@ -771,6 +771,8 @@ fhandler_console::setup ()
34+
con.disable_master_thread = true;
35+
con.master_thread_suspended = false;
36+
con.num_processed = 0;
37+
+ con.curr_input_mode = tty::restore;
38+
+ con.curr_output_mode = tty::restore;
39+
}
40+
}
41+
42+
@@ -849,11 +851,6 @@ fhandler_console::set_input_mode (tty::cons_mode m, const termios *t,
43+
flags |= ENABLE_PROCESSED_INPUT;
44+
break;
45+
}
46+
- if (con.curr_input_mode != tty::cygwin && m == tty::cygwin)
47+
- {
48+
- prev_input_mode_backup = con.prev_input_mode;
49+
- con.prev_input_mode = oflags;
50+
- }
51+
con.curr_input_mode = m;
52+
SetConsoleMode (p->input_handle, flags);
53+
if (!(oflags & ENABLE_VIRTUAL_TERMINAL_INPUT)
54+
@@ -893,11 +890,6 @@ fhandler_console::set_output_mode (tty::cons_mode m, const termios *t,
55+
flags |= DISABLE_NEWLINE_AUTO_RETURN;
56+
break;
57+
}
58+
- if (con.curr_output_mode != tty::cygwin && m == tty::cygwin)
59+
- {
60+
- prev_output_mode_backup = con.prev_output_mode;
61+
- GetConsoleMode (p->output_handle, &con.prev_output_mode);
62+
- }
63+
con.curr_output_mode = m;
64+
acquire_attach_mutex (mutex_timeout);
65+
DWORD resume_pid = attach_console (con.owner);
66+
@@ -1836,6 +1828,12 @@ fhandler_console::open (int flags, mode_t)
67+
handle_set.output_handle = h;
68+
release_output_mutex ();
69+
70+
+ if (con.owner == GetCurrentProcessId ())
71+
+ {
72+
+ GetConsoleMode (get_handle (), &con.prev_input_mode);
73+
+ GetConsoleMode (get_output_handle (), &con.prev_output_mode);
74+
+ }
75+
+
76+
wpbuf.init ();
77+
78+
handle_set.input_mutex = input_mutex;
79+
@@ -1881,6 +1879,19 @@ fhandler_console::open (int flags, mode_t)
80+
setenv ("TERM", "cygwin", 1);
81+
}
82+
83+
+ if (con.curr_input_mode != tty::cygwin)
84+
+ {
85+
+ prev_input_mode_backup = con.prev_input_mode;
86+
+ GetConsoleMode (get_handle (), &con.prev_input_mode);
87+
+ set_input_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
88+
+ }
89+
+ if (con.curr_output_mode != tty::cygwin)
90+
+ {
91+
+ prev_output_mode_backup = con.prev_output_mode;
92+
+ GetConsoleMode (get_output_handle (), &con.prev_output_mode);
93+
+ set_output_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
94+
+ }
95+
+
96+
debug_printf ("opened conin$ %p, conout$ %p", get_handle (),
97+
get_output_handle ());
98+
99+
@@ -4720,7 +4731,7 @@ fhandler_console::cons_mode_on_close (handle_set_t *p)
100+
NTSTATUS status =
101+
NtQueryInformationProcess (GetCurrentProcess (), ProcessBasicInformation,
102+
&pbi, sizeof (pbi), NULL);
103+
- if (NT_SUCCESS (status)
104+
+ if (NT_SUCCESS (status) && cygwin_pid (con.owner)
105+
&& !process_alive ((DWORD) pbi.InheritedFromUniqueProcessId))
106+
/* Execed from normal cygwin process and the parent has been exited. */
107+
return tty::cygwin;
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
From 7acbb031654404c9fd711eee9974c88475de98fd Mon Sep 17 00:00:00 2001
2+
From: Johannes Schindelin <[email protected]>
3+
Date: Wed, 7 May 2025 11:27:42 +0200
4+
Subject: [PATCH 52/N] ci: add an AutoHotKey-based integration test
5+
6+
The issue reported in https://github.com/microsoft/git/issues/730 was
7+
fixed, but due to missing tests for the issue a regression slipped in
8+
within mere weeks.
9+
10+
Let's add an integration test that will (hopefully) prevent this issue
11+
from regressing again.
12+
13+
This integration test is implement as an AutoHotKey script. It might
14+
look unnatural to use a script language designed to implement global
15+
keyboard shortcuts, but it is a quite powerful approach. While
16+
there are miles between the ease of developing AutoHotKey scripts and
17+
developing, say, Playwright tests, there is a decent integration into VS
18+
Code (including single-step debugging), and AutoHotKey's own development
19+
and community are quite vibrant and friendly.
20+
21+
I had looked at alternatives to AutoHotKey, such as WinAppDriver,
22+
SikuliX, nut.js and AutoIt, in particular searching for a solution that
23+
would have a powerful recording feature similar to Playwright, but did
24+
not find any that is 1) mature, 2) well-maintained, 3) open source and
25+
4) would be easy to integrate into a GitHub workflow. In the end,
26+
AutoHotKey appeared my clearest preference.
27+
28+
So how is the test implemented? It lives in `ui-test/` and requires
29+
AutoHotKey v2 as well as Windows Terminal (the Legacy Prompt would not
30+
reproduce the problem). It then follows the reproducer I gave to the
31+
Cygwin team:
32+
33+
1. initialize a Git repository
34+
2. install a `pre-commit` hook
35+
3. this hook shall spawn a non-Cygwin/MSYS2 process in the background
36+
4. that background process shall print to the console after Git exits
37+
5. open a Command Prompt in Windows Terminal
38+
6. run `git commit`
39+
7. wait until the background process is done printing
40+
8. press the Cursor Up key
41+
9. observe that the Command Prompt does not react (in the test, it
42+
_does_ expect a reaction: the previous command in the command
43+
history should be shown, i.e. `git commit`)
44+
45+
In my reproducer, I then also suggested to press the Enter key and to
46+
observe that now the "More ?" prompt is shown, but no input is accepted,
47+
until Ctrl+Z is pressed. Naturally, the test should not expect _that_
48+
;-)
49+
50+
There were a couple of complications I needed to face when developing
51+
this test:
52+
53+
- I did not find any easy macro recorder for AutoHotKey that I liked. It
54+
would not have helped much, anyway, because intentions are hard to
55+
record.
56+
57+
- Before I realized that there is excellent AutoHotKey support in VS
58+
Code via the AutoHotKey++ and AutoHotKey Debug extensions, I struggled
59+
quite a bit to get the syntax right.
60+
61+
- Windows Terminal does not use classical Win32 controls that AutoHotKey
62+
knows well. In particular, there is no easy way to capture the text
63+
that is shown in the Terminal. I tried the (pretty excellent!) [OCR
64+
for AutoHotKey](https://github.com/Descolada/OCR), but it uses UWP OCR
65+
which does not recognize constructs like "C:\Users\runneradmin>"
66+
because it is not English (or any other human language). I ended up
67+
with a pretty inelegant method of selecting the text via mouse
68+
movements and then copying that into the clipboard. This stops
69+
scrolling and I worked around that by emulating the mouse wheel
70+
afterwards.
71+
72+
- Since Windows Terminal does not use classical Win32 controls, it is
73+
relatively hard to get to the exact bounding box of the text, as there
74+
is no convenient way to determine the size of the title bar or the
75+
amount of padding around the text. I ended up hard-coding those
76+
values, I'm not proud of that, but at least it works.
77+
78+
- Despite my expectations, `ExitApp` would not actually exit AutoHotKey
79+
before the spawned process exits and/or the associated window is
80+
closed.
81+
82+
Signed-off-by: Johannes Schindelin <[email protected]>
83+
---
84+
ui-tests/background-hook.ahk | 129 +++++++++++++++++++++++++++++++++++
85+
1 file changed, 129 insertions(+)
86+
create mode 100755 ui-tests/background-hook.ahk
87+
88+
diff --git a/ui-tests/background-hook.ahk b/ui-tests/background-hook.ahk
89+
new file mode 100755
90+
index 0000000..43f723b
91+
--- /dev/null
92+
+++ b/ui-tests/background-hook.ahk
93+
@@ -0,0 +1,129 @@
94+
+#Requires AutoHotkey v2.0
95+
+
96+
+; This script is an integration test for the following scenario:
97+
+; A Git hook spawns a background process that outputs some text
98+
+; to the console even after Git has exited.
99+
+
100+
+; At some point in time, the Cygwin/MSYS2 runtime left the console
101+
+; in a state where it was not possible to navigate the history via
102+
+; CursorUp/Down, as reported in https://github.com/microsoft/git/issues/730.
103+
+; This was fixed in the Cygwin/MSYS2 runtime, but then regressed again.
104+
+; This test is meant to verify that the issue is fixed and remains so.
105+
+
106+
+; First, set the worktree path; This path will be reused
107+
+; for the `.log` file).
108+
+if A_Args.Length > 0
109+
+ workTree := A_Args[1]
110+
+else
111+
+{
112+
+ ; Create a unique worktree path in the TEMP directory.
113+
+ workTree := EnvGet('TEMP') . '\git-test-background-hook'
114+
+ if FileExist(workTree)
115+
+ {
116+
+ counter := 0
117+
+ while FileExist(workTree '-' counter)
118+
+ counter++
119+
+ workTree := workTree '-' counter
120+
+ }
121+
+}
122+
+
123+
+Info(text) {
124+
+ FileAppend text '`n', workTree '.log'
125+
+}
126+
+
127+
+closeWindow := false
128+
+childPid := 0
129+
+ExitWithError(error) {
130+
+ Info 'Error: ' error
131+
+ if closeWindow
132+
+ WinClose "A"
133+
+ else if childPid != 0
134+
+ ProcessClose childPid
135+
+ ExitApp 1
136+
+}
137+
+
138+
+RunWaitOne(command) {
139+
+ shell := ComObject("WScript.Shell")
140+
+ ; Execute a single command via cmd.exe
141+
+ exec := shell.Exec(A_ComSpec " /C " command)
142+
+ ; Read and return the command's output
143+
+ return exec.StdOut.ReadAll()
144+
+}
145+
+
146+
+SetWorkingDir(EnvGet('TEMP'))
147+
+Info 'uname: ' RunWaitOne('uname -a')
148+
+Info RunWaitOne('git version --build-options')
149+
+
150+
+RunWait('git init "' workTree '"', '', 'Hide')
151+
+if A_LastError
152+
+ ExitWithError 'Could not initialize Git worktree at: ' workTree
153+
+
154+
+SetWorkingDir(workTree)
155+
+if A_LastError
156+
+ ExitWithError 'Could not set working directory to: ' workTree
157+
+
158+
+if not FileExist('.git/hooks') and not DirCreate('.git/hooks')
159+
+ ExitWithError 'Could not create hooks directory: ' workTree
160+
+
161+
+FileAppend("#!/bin/sh`npowershell -command 'for ($i = 0; $i -lt 50; $i++) { echo $i; sleep -milliseconds 10 }' &`n", '.git/hooks/pre-commit')
162+
+if A_LastError
163+
+ ExitWithError 'Could not create pre-commit hook: ' A_LastError
164+
+
165+
+Run 'wt.exe -d . ' A_ComSpec ' /d', , , &childPid
166+
+if A_LastError
167+
+ ExitWithError 'Error launching CMD: ' A_LastError
168+
+Info 'Launched CMD: ' childPid
169+
+if not WinWait(A_ComSpec, , 9)
170+
+ ExitWithError 'CMD window did not appear'
171+
+Info 'Got window'
172+
+WinActivate
173+
+CloseWindow := true
174+
+WinMove 0, 0
175+
+Info 'Moved window to top left (so that the bottom is not cut off)'
176+
+
177+
+CaptureText() {
178+
+ ControlGetPos &cx, &cy, &cw, &ch, 'Windows.UI.Composition.DesktopWindowContentBridge1', "A"
179+
+ titleBarHeight := 54
180+
+ scrollBarWidth := 28
181+
+ pad := 8
182+
+
183+
+ SavedClipboard := ClipboardAll
184+
+ A_Clipboard := ''
185+
+ SendMode('Event')
186+
+ MouseMove cx + pad, cy + titleBarHeight + pad
187+
+ MouseClickDrag 'Left', , , cx + cw - scrollBarWidth, cy + ch - pad, , ''
188+
+ MouseClick 'Right'
189+
+ ClipWait()
190+
+ Result := A_Clipboard
191+
+ Clipboard := SavedClipboard
192+
+ return Result
193+
+}
194+
+
195+
+Info('Setting committer identity')
196+
+Send('git config user.name Test{Enter}git config user.email [email protected]{Enter}')
197+
+
198+
+Info('Committing')
199+
+Send('git commit --allow-empty -m zOMG{Enter}')
200+
+; Wait for the hook to finish printing
201+
+While not RegExMatch(CaptureText(), '`n49$')
202+
+{
203+
+ Sleep 100
204+
+ if A_Index > 1000
205+
+ ExitWithError 'Timed out waiting for commit to finish'
206+
+ MouseClick 'WheelDown', , , 20
207+
+}
208+
+Info('Hook finished')
209+
+
210+
+; Verify that CursorUp shows the previous command
211+
+Send('{Up}')
212+
+Sleep 150
213+
+Text := CaptureText()
214+
+if not RegExMatch(Text, 'git commit --allow-empty -m zOMG *$')
215+
+ ExitWithError 'Cursor Up did not work: ' Text
216+
+Info('Match!')
217+
+
218+
+Send('^C')
219+
+Send('exit{Enter}')
220+
+Sleep 50
221+
+SetWorkingDir(EnvGet('TEMP'))
222+
+DirDelete(workTree, true)
223+
\ No newline at end of file

0 commit comments

Comments
 (0)