fsmonitor: rename fsm-ipc-darwin.c to fsm-ipc-unix.c

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 <edecosta@mathworks.com> Based-on-patch-by: Marziyeh Esipreh <marziyeh.esipreh@gmail.com> Signed-off-by: Paul Tarjan <github@paulisageek.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Paul Tarjan committed Apr 15, 2026 at 13:27 UTC ff384ebfad074321e22b2fb310a8f35df19576d6
5 files changed +21 -19
Makefile
+3 -3
@@ -408,7 +408,7 @@ include shared.mak
408 # If your platform has OS-specific ways to tell if a repo is incompatible with
409 # fsmonitor (whether the hook or IPC daemon version), set FSMONITOR_OS_SETTINGS
410 # to the "<name>" of the corresponding `compat/fsmonitor/fsm-settings-<name>.c`
411 -# that implements the `fsm_os_settings__*()` routines.
411 +# and `compat/fsmonitor/fsm-ipc-<name>.c` files.
412 #
413 # Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
414 # programs in oss-fuzz/.
@@ -2323,13 +2323,13 @@ ifdef FSMONITOR_DAEMON_BACKEND
2323 COMPAT_CFLAGS += -DHAVE_FSMONITOR_DAEMON_BACKEND
2324 COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o
2325 COMPAT_OBJS += compat/fsmonitor/fsm-health-$(FSMONITOR_DAEMON_BACKEND).o
2326 - COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_DAEMON_BACKEND).o
2326 endif
2327
2328 ifdef FSMONITOR_OS_SETTINGS
2329 COMPAT_CFLAGS += -DHAVE_FSMONITOR_OS_SETTINGS
2330 + COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_OS_SETTINGS).o
2331 COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_OS_SETTINGS).o
2332 - COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
2332 + COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_DAEMON_BACKEND).o
2333 endif
2334
2335 ifdef WITH_BREAKING_CHANGES
compat/fsmonitor/fsm-ipc-unix.c renamed
config.mak.uname
+1 -1
@@ -178,7 +178,7 @@ ifeq ($(uname_S),Darwin)
178 ifndef NO_PTHREADS
179 ifndef NO_UNIX_SOCKETS
180 FSMONITOR_DAEMON_BACKEND = darwin
181 - FSMONITOR_OS_SETTINGS = darwin
181 + FSMONITOR_OS_SETTINGS = unix
182 endif
183 endif
184
contrib/buildsystems/CMakeLists.txt
+12 -13
@@ -291,23 +291,22 @@ endif()
291
292 if(SUPPORTS_SIMPLE_IPC)
293 if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
294 - add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
295 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-win32.c)
296 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-health-win32.c)
297 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-ipc-win32.c)
298 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-path-utils-win32.c)
299 -
300 - add_compile_definitions(HAVE_FSMONITOR_OS_SETTINGS)
301 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-settings-win32.c)
294 + set(FSMONITOR_DAEMON_BACKEND "win32")
295 + set(FSMONITOR_OS_SETTINGS "win32")
296 elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
297 + set(FSMONITOR_DAEMON_BACKEND "darwin")
298 + set(FSMONITOR_OS_SETTINGS "unix")
299 + endif()
300 +
301 + if(FSMONITOR_DAEMON_BACKEND)
302 add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
304 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-darwin.c)
305 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-health-darwin.c)
306 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-ipc-darwin.c)
307 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-path-utils-darwin.c)
303 + list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-${FSMONITOR_DAEMON_BACKEND}.c)
304 + list(APPEND compat_SOURCES compat/fsmonitor/fsm-health-${FSMONITOR_DAEMON_BACKEND}.c)
305 + list(APPEND compat_SOURCES compat/fsmonitor/fsm-ipc-${FSMONITOR_OS_SETTINGS}.c)
306 + list(APPEND compat_SOURCES compat/fsmonitor/fsm-path-utils-${FSMONITOR_DAEMON_BACKEND}.c)
307
308 add_compile_definitions(HAVE_FSMONITOR_OS_SETTINGS)
310 - list(APPEND compat_SOURCES compat/fsmonitor/fsm-settings-darwin.c)
309 + list(APPEND compat_SOURCES compat/fsmonitor/fsm-settings-${FSMONITOR_DAEMON_BACKEND}.c)
310 endif()
311 endif()
312
meson.build
+5 -2
@@ -1320,10 +1320,13 @@ else
1320 endif
1321
1322 fsmonitor_backend = ''
1323 +fsmonitor_os = ''
1324 if host_machine.system() == 'windows'
1325 fsmonitor_backend = 'win32'
1326 + fsmonitor_os = 'win32'
1327 elif host_machine.system() == 'darwin'
1328 fsmonitor_backend = 'darwin'
1329 + fsmonitor_os = 'unix'
1330 libgit_dependencies += dependency('CoreServices')
1331 endif
1332 if fsmonitor_backend != ''
@@ -1332,14 +1335,14 @@ if fsmonitor_backend != ''
1335
1336 libgit_sources += [
1337 'compat/fsmonitor/fsm-health-' + fsmonitor_backend + '.c',
1335 - 'compat/fsmonitor/fsm-ipc-' + fsmonitor_backend + '.c',
1338 + 'compat/fsmonitor/fsm-ipc-' + fsmonitor_os + '.c',
1339 'compat/fsmonitor/fsm-listen-' + fsmonitor_backend + '.c',
1340 'compat/fsmonitor/fsm-path-utils-' + fsmonitor_backend + '.c',
1341 'compat/fsmonitor/fsm-settings-' + fsmonitor_backend + '.c',
1342 ]
1343 endif
1344 build_options_config.set_quoted('FSMONITOR_DAEMON_BACKEND', fsmonitor_backend)
1342 -build_options_config.set_quoted('FSMONITOR_OS_SETTINGS', fsmonitor_backend)
1345 +build_options_config.set_quoted('FSMONITOR_OS_SETTINGS', fsmonitor_os)
1346
1347 if not get_option('b_sanitize').contains('address') and get_option('regex').allowed() and compiler.has_header('regex.h') and compiler.get_define('REG_STARTEND', prefix: '#include <regex.h>') != ''
1348 build_options_config.set('NO_REGEX', '')