git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/1] t6500(mingw): use the Windows PID of the shell

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
May 7, 2019, 21:51 UTC
Message-ID
<ba78a47b873c5f044cbfb147b30a801cc90fb0ac.1557265888.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.185.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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 <johannes.schindelin@gmx.de>
---
 t/t6500-gc.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
index 4684d06552..53258d45a1 100755
--- a/t/t6500-gc.sh
+++ b/t/t6500-gc.sh
@@ -162,7 +162,15 @@ test_expect_success 'background auto gc respects lock for all operations' '
 	# now fake a concurrent gc that holds the lock; we can use our
 	# shell pid so that it looks valid.
 	hostname=$(hostname || echo unknown) &&
-	printf "$$ %s" "$hostname" >.git/gc.pid &&
+	shell_pid=$$ &&
+	if test_have_prereq MINGW && test -f /proc/$shell_pid/winpid
+	then
+		# In Git for Windows, Bash (actually, the MSYS2 runtime) has a
+		# different idea of PIDs than git.exe (actually Windows). Use
+		# the Windows PID in this case.
+		shell_pid=$(cat /proc/$shell_pid/winpid)
+	fi &&
+	printf "%d %s" "$shell_pid" "$hostname" >.git/gc.pid &&
 
 	# our gc should exit zero without doing anything
 	run_and_wait_for_auto_gc &&
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Eric Sunshine
Message 2 of 5 in “Proactively fix a test issue with v3.x of the MSYS2 runtime”
  1. 0/1 Proactively fix a test issue with v3.x of the MSYS2 runtimeJohannes Schindelin via GitGitGadget, May 7, 2019
  2. 1/1 t6500(mingw): use the Windows PID of the shellJohannes Schindelin via GitGitGadget, May 7, 2019
  3. Eric SunshineMay 7, 2019
  4. Junio C HamanoMay 8, 2019
  5. Junio C HamanoMay 8, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.