Merge branch 'js/t6500-use-windows-pid-on-mingw'
authorJunio C Hamano <gitster@pobox.com>
Sun, 19 May 2019 07:45:29 +0000 (16:45 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 May 2019 07:45:29 +0000 (16:45 +0900)
Future-proof a test against an update to MSYS2 runtime v3.x series.

* js/t6500-use-windows-pid-on-mingw:
t6500(mingw): use the Windows PID of the shell

t/t6500-gc.sh
index 7411bf7fecd89984c7256668863c9f96bb75efbf..515c6735e9cb076c9f4b5a252c48216765b5076a 100755 (executable)
@@ -181,7 +181,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 &&