<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/compat/fsmonitor, branch seen</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=seen</id>
<link rel='self' href='https://git.shady.money/git/atom?h=seen'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2026-04-15T15:44:33Z</updated>
<entry>
<title>fsmonitor: implement filesystem change listener for Linux</title>
<updated>2026-04-15T15:44:33Z</updated>
<author>
<name>Paul Tarjan</name>
<email>github@paulisageek.com</email>
</author>
<published>2026-04-15T13:27:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ce48de8b2c85a4e5cbeb5dd1f2cfe042dd5392e4'/>
<id>urn:sha1:ce48de8b2c85a4e5cbeb5dd1f2cfe042dd5392e4</id>
<content type='text'>
Implement the built-in fsmonitor daemon for Linux using the inotify
API, bringing it to feature parity with the existing Windows and macOS
implementations.

The implementation uses inotify rather than fanotify because fanotify
requires either CAP_SYS_ADMIN or CAP_PERFMON capabilities, making it
unsuitable for an unprivileged user-space daemon.  While inotify has
the limitation of requiring a separate watch on every directory (unlike
macOS's FSEvents, which can monitor an entire directory tree with a
single watch), it operates without elevated privileges and provides
the per-file event granularity needed for fsmonitor.

The listener uses inotify_init1(O_NONBLOCK) with a poll loop that
checks for events with a 50-millisecond timeout, keeping the inotify
queue well-drained to minimize the risk of overflows.  Bidirectional
hashmaps map between watch descriptors and directory paths for efficient
event resolution.  Directory renames are tracked using inotify's cookie
mechanism to correlate IN_MOVED_FROM and IN_MOVED_TO event pairs; a
periodic check detects stale renames where the matching IN_MOVED_TO
never arrived, forcing a resync.

New directory creation triggers recursive watch registration to ensure
all subdirectories are monitored.  The IN_MASK_CREATE flag is used
where available to prevent modifying existing watches, with a fallback
for older kernels.  When IN_MASK_CREATE is available and
inotify_add_watch returns EEXIST, it means another thread or recursive
scan has already registered the watch, so it is safe to ignore.

Remote filesystem detection uses statfs() to identify network-mounted
filesystems (NFS, CIFS, SMB, FUSE, etc.) via their magic numbers.
Mount point information is read from /proc/mounts and matched against
the statfs f_fsid to get accurate, human-readable filesystem type names
for logging.  When the .git directory is on a remote filesystem, the
IPC socket falls back to $HOME or a user-configured directory via the
fsmonitor.socketDir setting.

Based-on-patch-by: Eric DeCosta &lt;edecosta@mathworks.com&gt;
Based-on-patch-by: Marziyeh Esipreh &lt;marziyeh.esipreh@gmail.com&gt;
Signed-off-by: Paul Tarjan &lt;github@paulisageek.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fsmonitor: rename fsm-settings-darwin.c to fsm-settings-unix.c</title>
<updated>2026-04-15T15:44:33Z</updated>
<author>
<name>Paul Tarjan</name>
<email>github@paulisageek.com</email>
</author>
<published>2026-04-15T13:27:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7422200bfa1728139962cbf7481f8945add9689e'/>
<id>urn:sha1:7422200bfa1728139962cbf7481f8945add9689e</id>
<content type='text'>
The fsmonitor settings logic in fsm-settings-darwin.c is not
Darwin-specific and will be reused by the upcoming Linux
implementation.  Rename it to fsm-settings-unix.c to reflect that it
is shared by all Unix platforms.

Update the build files (meson.build and CMakeLists.txt) to use
FSMONITOR_OS_SETTINGS for fsm-settings, matching the approach already
used for fsm-ipc.

Based-on-patch-by: Eric DeCosta &lt;edecosta@mathworks.com&gt;
Based-on-patch-by: Marziyeh Esipreh &lt;marziyeh.esipreh@gmail.com&gt;
Signed-off-by: Paul Tarjan &lt;github@paulisageek.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fsmonitor: rename fsm-ipc-darwin.c to fsm-ipc-unix.c</title>
<updated>2026-04-15T15:44:33Z</updated>
<author>
<name>Paul Tarjan</name>
<email>github@paulisageek.com</email>
</author>
<published>2026-04-15T13:27:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ff384ebfad074321e22b2fb310a8f35df19576d6'/>
<id>urn:sha1:ff384ebfad074321e22b2fb310a8f35df19576d6</id>
<content type='text'>
The fsmonitor IPC path logic in fsm-ipc-darwin.c is not
Darwin-specific and will be reused by the upcoming Linux
implementation.  Rename it to fsm-ipc-unix.c to reflect that it
is shared by all Unix platforms.

Introduce FSMONITOR_OS_SETTINGS (set to "unix" for non-Windows, "win32"
for Windows) as a separate variable from FSMONITOR_DAEMON_BACKEND so
that the build files can distinguish between platform-specific files
(listen, health, path-utils) and shared Unix files (ipc, settings).

Move fsm-ipc to the FSMONITOR_OS_SETTINGS section in the Makefile, and
switch fsm-path-utils to use FSMONITOR_DAEMON_BACKEND since path-utils
is platform-specific (there will be separate darwin and linux versions).

Based-on-patch-by: Eric DeCosta &lt;edecosta@mathworks.com&gt;
Based-on-patch-by: Marziyeh Esipreh &lt;marziyeh.esipreh@gmail.com&gt;
Signed-off-by: Paul Tarjan &lt;github@paulisageek.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>global: trivial conversions to fix `-Wsign-compare` warnings</title>
<updated>2024-12-06T11:20:04Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=80c9e70ebe871f0826bc101142c66ff783405100'/>
<id>urn:sha1:80c9e70ebe871f0826bc101142c66ff783405100</id>
<content type='text'>
We have a bunch of loops which iterate up to an unsigned boundary using
a signed index, which generates warnigs because we compare a signed and
unsigned value in the loop condition. Address these sites for trivial
cases and enable `-Wsign-compare` warnings for these code units.

This patch only adapts those code units where we can drop the
`DISABLE_SIGN_COMPARE_WARNINGS` macro in the same step.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>global: mark code units that generate warnings with `-Wsign-compare`</title>
<updated>2024-12-06T11:20:02Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-12-06T10:27:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=41f43b8243f42b9df2e98be8460646d4c0100ad3'/>
<id>urn:sha1:41f43b8243f42b9df2e98be8460646d4c0100ad3</id>
<content type='text'>
Mark code units that generate warnings with `-Wsign-compare`. This
allows for a structured approach to get rid of all such warnings over
time in a way that can be easily measured.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ak/typofixes'</title>
<updated>2024-10-25T18:02:04Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2024-10-25T18:02:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4d334e5205f547be7913901d0cf529477e993f26'/>
<id>urn:sha1:4d334e5205f547be7913901d0cf529477e993f26</id>
<content type='text'>
Typofixes.

* ak/typofixes:
  t: fix typos
  t/helper: fix a typo
  t/perf: fix typos
  t/unit-tests: fix typos
  contrib: fix typos
  compat: fix typos
</content>
</entry>
<entry>
<title>Merge branch 'jk/fsmonitor-event-listener-race-fix'</title>
<updated>2024-10-15T20:56:43Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2024-10-15T20:56:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b43e23fa02427067ceb605a5dd5ea602de4c6ac5'/>
<id>urn:sha1:b43e23fa02427067ceb605a5dd5ea602de4c6ac5</id>
<content type='text'>
On macOS, fsmonitor can fall into a race condition that results in
a client waiting forever to be notified for an event that have
already happened.  This problem has been corrected.

* jk/fsmonitor-event-listener-race-fix:
  fsmonitor: initialize fs event listener before accepting clients
  simple-ipc: split async server initialization and running
</content>
</entry>
<entry>
<title>compat: fix typos</title>
<updated>2024-10-10T20:31:12Z</updated>
<author>
<name>Andrew Kreimer</name>
<email>algonell@gmail.com</email>
</author>
<published>2024-10-10T15:11:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=54ee29cfd521b0e043dcc1857e4a7c8d993b5e59'/>
<id>urn:sha1:54ee29cfd521b0e043dcc1857e4a7c8d993b5e59</id>
<content type='text'>
Fix typos and grammar.

Reported-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Andrew Kreimer &lt;algonell@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fsmonitor: initialize fs event listener before accepting clients</title>
<updated>2024-10-08T19:03:56Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-10-08T08:36:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=51907f8feeae9ae4af1722e973f44ff10aa168dc'/>
<id>urn:sha1:51907f8feeae9ae4af1722e973f44ff10aa168dc</id>
<content type='text'>
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-&gt;stream, data-&gt;dq);
          data-&gt;stream_scheduled = 1;

  +       sleep(1);
          if (!FSEventStreamStart(data-&gt;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 &lt;koji.nakamaru@gree.net&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Acked-by: Koji Nakamaru &lt;koji.nakamaru@gree.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>global: prepare for hiding away repo-less config functions</title>
<updated>2024-08-13T17:01:05Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2024-08-13T09:14:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=219de841d9436d759fa52ea60625b60cda8476fd'/>
<id>urn:sha1:219de841d9436d759fa52ea60625b60cda8476fd</id>
<content type='text'>
We're about to hide config functions that implicitly depend on
`the_repository` behind the `USE_THE_REPOSITORY_VARIABLE` macro. This
will uncover a bunch of dependents that transitively relied on the
global variable, but didn't define the macro yet.

Adapt them such that we define the macro to prepare for this change.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
