mirror of
https://github.com/git/git.git
synced 2026-03-04 22:47:35 +01:00
fsmonitor: deduplicate IPC path logic for Unix platforms
The macOS fsm-ipc-darwin.c is applicable to other Unix variants as well. Rename it to fsm-ipc-unix.c and add a worktree NULL check (BUG guard) that was missing from the macOS version. To support this, introduce FSMONITOR_OS_SETTINGS which is set to "unix" for both macOS and Linux, distinct from FSMONITOR_DAEMON_BACKEND which remains platform-specific (darwin, linux, win32). Move fsm-path-utils from FSMONITOR_OS_SETTINGS to FSMONITOR_DAEMON_BACKEND since the path-utils files are platform-specific. Signed-off-by: Paul Tarjan <github@paulisageek.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
25351303cd
commit
72b1daeb13
8
Makefile
8
Makefile
@@ -2323,13 +2323,17 @@ ifdef FSMONITOR_DAEMON_BACKEND
|
||||
COMPAT_CFLAGS += -DHAVE_FSMONITOR_DAEMON_BACKEND
|
||||
COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o
|
||||
COMPAT_OBJS += compat/fsmonitor/fsm-health-$(FSMONITOR_DAEMON_BACKEND).o
|
||||
COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_DAEMON_BACKEND).o
|
||||
ifeq ($(FSMONITOR_DAEMON_BACKEND),win32)
|
||||
COMPAT_OBJS += compat/fsmonitor/fsm-ipc-win32.o
|
||||
else
|
||||
COMPAT_OBJS += compat/fsmonitor/fsm-ipc-unix.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef FSMONITOR_OS_SETTINGS
|
||||
COMPAT_CFLAGS += -DHAVE_FSMONITOR_OS_SETTINGS
|
||||
COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_OS_SETTINGS).o
|
||||
COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
|
||||
COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_DAEMON_BACKEND).o
|
||||
endif
|
||||
|
||||
ifdef WITH_BREAKING_CHANGES
|
||||
|
||||
@@ -27,13 +27,15 @@ const char *fsmonitor_ipc__get_path(struct repository *r)
|
||||
if (ipc_path)
|
||||
return ipc_path;
|
||||
|
||||
|
||||
/* By default the socket file is created in the .git directory */
|
||||
if (fsmonitor__is_fs_remote(r->gitdir) < 1) {
|
||||
ipc_path = fsmonitor_ipc__get_default_path();
|
||||
return ipc_path;
|
||||
}
|
||||
|
||||
if (!r->worktree)
|
||||
BUG("repository has no worktree");
|
||||
|
||||
git_SHA1_Init(&sha1ctx);
|
||||
git_SHA1_Update(&sha1ctx, r->worktree, strlen(r->worktree));
|
||||
git_SHA1_Final(hash, &sha1ctx);
|
||||
@@ -303,7 +303,7 @@ if(SUPPORTS_SIMPLE_IPC)
|
||||
add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
|
||||
list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-darwin.c)
|
||||
list(APPEND compat_SOURCES compat/fsmonitor/fsm-health-darwin.c)
|
||||
list(APPEND compat_SOURCES compat/fsmonitor/fsm-ipc-darwin.c)
|
||||
list(APPEND compat_SOURCES compat/fsmonitor/fsm-ipc-unix.c)
|
||||
list(APPEND compat_SOURCES compat/fsmonitor/fsm-path-utils-darwin.c)
|
||||
|
||||
add_compile_definitions(HAVE_FSMONITOR_OS_SETTINGS)
|
||||
|
||||
@@ -1332,11 +1332,16 @@ if fsmonitor_backend != ''
|
||||
|
||||
libgit_sources += [
|
||||
'compat/fsmonitor/fsm-health-' + fsmonitor_backend + '.c',
|
||||
'compat/fsmonitor/fsm-ipc-' + fsmonitor_backend + '.c',
|
||||
'compat/fsmonitor/fsm-listen-' + fsmonitor_backend + '.c',
|
||||
'compat/fsmonitor/fsm-path-utils-' + fsmonitor_backend + '.c',
|
||||
'compat/fsmonitor/fsm-settings-' + fsmonitor_backend + '.c',
|
||||
]
|
||||
|
||||
if fsmonitor_backend == 'win32'
|
||||
libgit_sources += 'compat/fsmonitor/fsm-ipc-win32.c'
|
||||
else
|
||||
libgit_sources += 'compat/fsmonitor/fsm-ipc-unix.c'
|
||||
endif
|
||||
endif
|
||||
build_options_config.set_quoted('FSMONITOR_DAEMON_BACKEND', fsmonitor_backend)
|
||||
build_options_config.set_quoted('FSMONITOR_OS_SETTINGS', fsmonitor_backend)
|
||||
|
||||
Reference in New Issue
Block a user