Skip to content

Commit ba78a47

Browse files
committed
t6500(mingw): use the Windows PID of the shell
In Git for Windows, we use the MSYS2 Bash which inherits a non-standard PID model from Cygwin's POSIX emulation layer: every MSYS2 process has a regular Windows PID, and in addition it has an MSYS2 PID (which corresponds to a shadow process that emulates Unix-style signal handling). With the upgrade to the MSYS2 runtime v3.x, this shadow process cannot be accessed via `OpenProcess()` any longer, and therefore t6500 thought incorrectly that the process referenced in `gc.pid` (which is not actually a real `gc` process in this context, but the current shell) no longer exists. Let's fix this by making sure that the Windows PID is written into `gc.pid` in this test script soo that `git.exe` is able to understand that that process does indeed still exist. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8104ec9 commit ba78a47

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

t/t6500-gc.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,15 @@ test_expect_success 'background auto gc respects lock for all operations' '
162162
# now fake a concurrent gc that holds the lock; we can use our
163163
# shell pid so that it looks valid.
164164
hostname=$(hostname || echo unknown) &&
165-
printf "$$ %s" "$hostname" >.git/gc.pid &&
165+
shell_pid=$$ &&
166+
if test_have_prereq MINGW && test -f /proc/$shell_pid/winpid
167+
then
168+
# In Git for Windows, Bash (actually, the MSYS2 runtime) has a
169+
# different idea of PIDs than git.exe (actually Windows). Use
170+
# the Windows PID in this case.
171+
shell_pid=$(cat /proc/$shell_pid/winpid)
172+
fi &&
173+
printf "%d %s" "$shell_pid" "$hostname" >.git/gc.pid &&
166174
167175
# our gc should exit zero without doing anything
168176
run_and_wait_for_auto_gc &&

0 commit comments

Comments
 (0)