Skip to content

Commit ff00eee

Browse files
committed
fsmonitor-settings: stub in platform-specific incompatibility checking
Extend generic incompatibility checkout with platform-specific mechanism. Stub in Win32 version. In the existing fsmonitor-settings code we have a way to mark types of repos as incompatible with fsmonitor (whether via the hook and ipc APIs). For example, we do this for bare repos, since there are no files to watch. Extend this exclusion mechanism for platfor-specific reasons. This commit just creates the framework and adds a stub for Win32. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 8956648 commit ff00eee

File tree

6 files changed

+54
-0
lines changed

6 files changed

+54
-0
lines changed

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ all::
472472
# `compat/fsmonitor/fsm-listen-<name>.c` that implements the
473473
# `fsm_listen__*()` routines.
474474
#
475+
# If your platform has os-specific ways to tell if a repo is incompatible with
476+
# fsmonitor (whether the hook or ipc daemon version), set FSMONITOR_OS_SETTINGS
477+
# to the "<name>" of the corresponding `compat/fsmonitor/fsm-settings-<name>.c`
478+
# that implements the `fsm_os_settings__*()` routines.
479+
#
475480
# Define DEVELOPER to enable more compiler warnings. Compiler version
476481
# and family are auto detected, but could be overridden by defining
477482
# COMPILER_FEATURES (see config.mak.dev). You can still set
@@ -1940,6 +1945,11 @@ ifdef FSMONITOR_DAEMON_BACKEND
19401945
COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o
19411946
endif
19421947

1948+
ifdef FSMONITOR_OS_SETTINGS
1949+
COMPAT_CFLAGS += -DHAVE_FSMONITOR_OS_SETTINGS
1950+
COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_OS_SETTINGS).o
1951+
endif
1952+
19431953
ifeq ($(TCLTK_PATH),)
19441954
NO_TCLTK = NoThanks
19451955
endif
@@ -2807,6 +2817,9 @@ GIT-BUILD-OPTIONS: FORCE
28072817
ifdef FSMONITOR_DAEMON_BACKEND
28082818
@echo FSMONITOR_DAEMON_BACKEND=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_DAEMON_BACKEND)))'\' >>$@+
28092819
endif
2820+
ifdef FSMONITOR_OS_SETTINGS
2821+
@echo FSMONITOR_OS_SETTINGS=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_OS_SETTINGS)))'\' >>$@+
2822+
endif
28102823
ifdef TEST_OUTPUT_DIRECTORY
28112824
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
28122825
endif

compat/fsmonitor/fsm-settings-win32.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "cache.h"
2+
#include "config.h"
3+
#include "repository.h"
4+
#include "fsmonitor-settings.h"
5+
6+
enum fsmonitor_reason fsm_os__incompatible(struct repository *r)
7+
{
8+
return FSMONITOR_REASON_ZERO;
9+
}

config.mak.uname

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ ifeq ($(uname_S),Windows)
423423
#
424424
# SNPRINTF_RETURNS_BOGUS = YesPlease
425425
FSMONITOR_DAEMON_BACKEND = win32
426+
FSMONITOR_OS_SETTINGS = win32
426427
NO_SVN_TESTS = YesPlease
427428
RUNTIME_PREFIX = YesPlease
428429
HAVE_WPGMPTR = YesWeDo
@@ -602,6 +603,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
602603
NO_MKDTEMP = YesPlease
603604
NO_SVN_TESTS = YesPlease
604605
FSMONITOR_DAEMON_BACKEND = win32
606+
FSMONITOR_OS_SETTINGS = win32
605607
RUNTIME_PREFIX = YesPlease
606608
HAVE_WPGMPTR = YesWeDo
607609
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease

contrib/buildsystems/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
271271
list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-darwin.c)
272272
endif()
273273

274+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
275+
add_compile_definitions(HAVE_FSMONITOR_OS_SETTINGS)
276+
list(APPEND compat_SOURCES compat/fsmonitor/fsm-settings-win32.c)
277+
endif()
278+
274279
set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
275280

276281
#header checks

fsmonitor-settings.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ static int check_for_incompatible(struct repository *r)
3333
return 1;
3434
}
3535

36+
#ifdef HAVE_FSMONITOR_OS_SETTINGS
37+
{
38+
enum fsmonitor_reason reason;
39+
40+
reason = fsm_os__incompatible(r);
41+
if (reason != FSMONITOR_REASON_ZERO) {
42+
set_incompatible(r, reason);
43+
return 1;
44+
}
45+
}
46+
#endif
47+
3648
return 0;
3749
}
3850

fsmonitor-settings.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,17 @@ enum fsmonitor_reason fsm_settings__get_reason(struct repository *r,
2929

3030
struct fsmonitor_settings;
3131

32+
#ifdef HAVE_FSMONITOR_OS_SETTINGS
33+
/*
34+
* Ask platform-specific code whether the repository is incompatible
35+
* with fsmonitor (both hook and ipc modes). For example, if the working
36+
* directory is on a remote volume and mounted via a technology that does
37+
* not support notification events.
38+
*
39+
* fsm_os__* routines should considered private to fsm_settings__
40+
* routines.
41+
*/
42+
enum fsmonitor_reason fsm_os__incompatible(struct repository *r);
43+
#endif /* HAVE_FSMONITOR_OS_SETTINGS */
44+
3245
#endif /* FSMONITOR_SETTINGS_H */

0 commit comments

Comments
 (0)