Git without fork(2)

64 views
Skip to first unread message

ivan.t...@g5e.com

unread,
Aug 20, 2018, 4:26:13 PM8/20/18
to git-for-windows
In Mingw environment, fork(2) is not implemented. However, git-for-windows needs fork to work, using it to demultiplex data exchange involving sidebands.

So, how can one get git (built in MinGW) to do useful work? For build purposes, compat/mingw.c was patched with stub for a fork that always fails (from https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-git) - however in runtime attempt to clone would always fail, i.e.:

$ GIT_TRACE=1 git clone https://git.savannah.gnu.org/git/emacs.git --verbose
18:23:21.018391 exec-cmd.c:236          trace: resolved executable dir: D:/unix_env/mingw/bin
18:23:21.023407 git.c:415               trace: built-in: git clone https://git.savannah.gnu.org/git/emacs.git --verbose
Cloning into 'emacs'...
18:23:21.262618 run-command.c:637       trace: run_command: git remote-https origin https://git.savannah.gnu.org/git/emacs.git
18:23:21.283562 exec-cmd.c:236          trace: resolved executable dir: D:/unix_env/mingw/libexec/git-core
18:23:21.283562 git.c:654               trace: exec: git-remote-https origin https://git.savannah.gnu.org/git/emacs.git
18:23:21.283562 run-command.c:637       trace: run_command: git-remote-https origin https://git.savannah.gnu.org/git/emacs.git
18:23:21.311487 exec-cmd.c:236          trace: resolved executable dir: D:/unix_env/mingw/libexec/git-core
18:23:22.061619 run-command.c:637       trace: run_command: git fetch-pack --stateless-rpc --stdin --lock-pack --thin --check-self-contained-and-connected --cloning https://git.savannah.gnu.org/git/emacs.git/
18:23:22.081552 exec-cmd.c:236          trace: resolved executable dir: D:/unix_env/mingw/libexec/git-core
18:23:22.082535 git.c:415               trace: built-in: git fetch-pack --stateless-rpc --stdin --lock-pack --thin --check-self-contained-and-connected --cloning https://git.savannah.gnu.org/git/emacs.git/
POST git-upload-pack (gzip 15065 to 7758 bytes)
error: fork (async) failed: Function not implemented
fatal: fetch-pack: unable to fork off sideband demultiplexer

Johannes Sixt

unread,
Aug 21, 2018, 12:16:24 PM8/21/18
to ivan.t...@g5e.com, git-for-windows
If you look at the code where the error message is generated, you will
notice that it is inside an '#ifdef NO_PTHREADS' block:

https://github.com/git/git/blob/7e8bfb0412581daf8f3c89909f1d37844e8610dd/run-command.c#L1169

Therefore, the solution is to build Git with NO_PTHREADS undefined, IOW,
make sure that you have a pthreads emulation available.

-- Hannes

ivan.t...@g5e.com

unread,
Aug 22, 2018, 9:19:32 AM8/22/18
to git-for-windows
Thank you very much! configuring and building with pthreads solved the problem
Reply all
Reply to author
Forward
0 new messages