There's a racy hang in fsmonitor on macOS that we sometimes see in CI.
When we serve a client, what's supposed to happen is:
1. The client thread calls with_lock__wait_for_cookie() in which we
create a cookie file and then wait for a pthread_cond event
2. The filesystem event listener sees the cookie file creation, does
some internal book-keeping, and then triggers the pthread_cond.
But there's a problem: we start the listener that accepts client threads
before we start the fs event thread. So it's possible for us to accept a
client which creates the cookie file and starts waiting before the fs
event thread is initialized, and we miss those filesystem events
entirely. That leaves the client thread hanging forever.
In CI, the symptom is that t9210 (which is testing scalar, which always
enables fsmonitor under the hood) may hang forever in "scalar clone". It
is waiting on "git fetch" which is waiting on the fsmonitor daemon.
The race happens more frequently under load, but you can trigger it
predictably with a sleep like this, which delays the start of the fs
event thread:
--- a/compat/fsmonitor/fsm-listen-darwin.c
+++ b/compat/fsmonitor/fsm-listen-darwin.c
@@ -510,6 +510,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
FSEventStreamSetDispatchQueue(data->stream, data->dq);
data->stream_scheduled = 1;
+ sleep(1);
if (!FSEventStreamStart(data->stream)) {
error(_("Failed to start the FSEventStream"));
goto force_error_stop_without_loop;
One solution might be to reverse the order of initialization: start the
fs event thread before we start the thread listening for clients. But
the fsmonitor code explicitly does it in the opposite direction. The fs
event thread wants to refer to the ipc_server_data struct, so we need it
to be initialized first.
A further complication is that we need a signal from the fs event thread
that it is actually ready and listening. And those details happen within
backend-specific fsmonitor code, whereas the initialization is in the
shared code.
So instead, let's use the ipc_server init/start split added in the
previous commit. The generic fsmonitor code will init the ipc_server but
_not_ start it, leaving that to the backend specific code, which now
needs to call ipc_server_start_async() at the right time.
For macOS, that is right after we start the FSEventStream that you can
see in the diff above.
It's not clear to me if Windows suffers from the same problem (and we
simply don't trigger it in CI), or if it is immune. Regardless, the
obvious place to start accepting clients there is right after we've
established the ReadDirectoryChanges watch.
This makes the hangs go away in our macOS CI environment, even when
compiled with the sleep() above.
Helped-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Koji Nakamaru <koji.nakamaru@gree.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Git for Windows
This is Git for Windows, the Windows port of Git.
The Git for Windows project is run using a governance model. If you encounter problems, you can report them as GitHub issues, discuss them on Git for Windows' Google Group, and contribute bug fixes.
To build Git for Windows, please either install Git for Windows'
SDK, start its git-bash.exe, cd
to your Git worktree and run make, or open the Git worktree as a folder in
Visual Studio.
To verify that your build works, use one of the following methods:
-
If you want to test the built executables within Git for Windows' SDK, prepend
<worktree>/bin-wrappersto thePATH. -
Alternatively, run
make installin the Git worktree. -
If you need to test this in a full installer, run
sdk build git-and-installer. -
You can also "install" Git into an existing portable Git via
make install DESTDIR=<dir>where<dir>refers to the top-level directory of the portable Git. In this instance, you will want to prepend that portable Git's/cmddirectory to thePATH, or test by running that portable Git'sgit-bash.exeorgit-cmd.exe. -
If you built using a recent Visual Studio, you can use the menu item
Build>Install git(you will want to click onProject>CMake Settings for Gitfirst, then click onEdit JSONand then pointinstallRootto themingw64directory of an already-unpacked portable Git).As in the previous bullet point, you will then prepend
/cmdto thePATHor run using the portable Git'sgit-bash.exeorgit-cmd.exe. -
If you want to run the built executables in-place, but in a CMD instead of inside a Bash, you can run a snippet like this in the
git-bash.exewindow where Git was built (ensure that theEOFline has no leading spaces), and then paste into the CMD window what was put in the clipboard:clip.exe <<EOF set GIT_EXEC_PATH=$(cygpath -aw .) set PATH=$(cygpath -awp ".:contrib/scalar:/mingw64/bin:/usr/bin:$PATH") set GIT_TEMPLATE_DIR=$(cygpath -aw templates/blt) set GITPERLLIB=$(cygpath -aw perl/build/lib) EOF -
If you want to run the built executables in-place, but outside of Git for Windows' SDK, and without an option to set/override any environment variables (e.g. in Visual Studio's debugger), you can call the Git executable by its absolute path and use the
--exec-pathoption, like so:C:\git-sdk-64\usr\src\git\git.exe --exec-path=C:\git-sdk-64\usr\src\git helpNote: for this to work, you have to hard-link (or copy) the
.dllfiles from the/mingw64/bindirectory to the Git worktree, or add the/mingw64/bindirectory to thePATHsomehow or other.
To make sure that you are testing the correct binary, call ./git.exe version
in the Git worktree, and then call git version in a directory/window where
you want to test Git, and verify that they refer to the same version (you may
even want to pass the command-line option --build-options to look at the
exact commit from which the Git version was built).
Git - fast, scalable, distributed revision control system
Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.
Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.
Please read the file INSTALL for installation instructions.
Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.
See Documentation/gittutorial.txt to get started, then see
Documentation/giteveryday.txt for a useful minimum set of commands, and
Documentation/git-<commandname>.txt for documentation of each command.
If git has been correctly installed, then the tutorial can also be
read with man gittutorial or git help tutorial, and the
documentation of each command with man git-<commandname> or git help <commandname>.
CVS users may also want to read Documentation/gitcvs-migration.txt
(man gitcvs-migration or git help cvs-migration if git is
installed).
The user discussion and development of core Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission and Documentation/CodingGuidelines).
Those wishing to help with error message, usage and informational message
string translations (localization l10) should see po/README.md
(a po file is a Portable Object file that holds the translations).
To subscribe to the list, send an email to git+subscribe@vger.kernel.org (see https://subspace.kernel.org/subscribing.html for details). The mailing list archives are available at https://lore.kernel.org/git/, https://marc.info/?l=git and other archival sites. The core git mailing list is plain text (no HTML!).
Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.
The maintainer frequently sends the "What's cooking" reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.
The name "git" was given by Linus Torvalds when he wrote the very first version. He described the tool as "the stupid content tracker" and the name as (depending on your mood):
- random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of "get" may or may not be relevant.
- stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
- "global information tracker": you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
- "goddamn idiotic truckload of sh*t": when it breaks