Skip to content

Commit 2076a4e

Browse files
jeffhostetlerdscho
authored andcommitted
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 4cc3417 commit 2076a4e

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
@@ -476,6 +476,11 @@ all::
476476
# `compat/fsmonitor/fsm-listen-<name>.c` that implements the
477477
# `fsm_listen__*()` routines.
478478
#
479+
# If your platform has os-specific ways to tell if a repo is incompatible with
480+
# fsmonitor (whether the hook or ipc daemon version), set FSMONITOR_OS_SETTINGS
481+
# to the "<name>" of the corresponding `compat/fsmonitor/fsm-settings-<name>.c`
482+
# that implements the `fsm_os_settings__*()` routines.
483+
#
479484
# Define DEVELOPER to enable more compiler warnings. Compiler version
480485
# and family are auto detected, but could be overridden by defining
481486
# COMPILER_FEATURES (see config.mak.dev). You can still set
@@ -1951,6 +1956,11 @@ ifdef FSMONITOR_DAEMON_BACKEND
19511956
COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o
19521957
endif
19531958

1959+
ifdef FSMONITOR_OS_SETTINGS
1960+
COMPAT_CFLAGS += -DHAVE_FSMONITOR_OS_SETTINGS
1961+
COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_OS_SETTINGS).o
1962+
endif
1963+
19541964
ifeq ($(TCLTK_PATH),)
19551965
NO_TCLTK = NoThanks
19561966
endif
@@ -2834,6 +2844,9 @@ GIT-BUILD-OPTIONS: FORCE
28342844
ifdef FSMONITOR_DAEMON_BACKEND
28352845
@echo FSMONITOR_DAEMON_BACKEND=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_DAEMON_BACKEND)))'\' >>$@+
28362846
endif
2847+
ifdef FSMONITOR_OS_SETTINGS
2848+
@echo FSMONITOR_OS_SETTINGS=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_OS_SETTINGS)))'\' >>$@+
2849+
endif
28372850
ifdef TEST_OUTPUT_DIRECTORY
28382851
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
28392852
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ ifeq ($(uname_S),Windows)
435435
# These are always available, so we do not have to conditionally
436436
# support it.
437437
FSMONITOR_DAEMON_BACKEND = win32
438+
FSMONITOR_OS_SETTINGS = win32
439+
438440
NO_SVN_TESTS = YesPlease
439441
RUNTIME_PREFIX = YesPlease
440442
HAVE_WPGMPTR = YesWeDo
@@ -627,6 +629,8 @@ ifneq (,$(findstring MINGW,$(uname_S)))
627629
# These are always available, so we do not have to conditionally
628630
# support it.
629631
FSMONITOR_DAEMON_BACKEND = win32
632+
FSMONITOR_OS_SETTINGS = win32
633+
630634
RUNTIME_PREFIX = YesPlease
631635
HAVE_WPGMPTR = YesWeDo
632636
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease

contrib/buildsystems/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ if(SUPPORTS_SIMPLE_IPC)
314314
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
315315
add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
316316
list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-win32.c)
317+
318+
add_compile_definitions(HAVE_FSMONITOR_OS_SETTINGS)
319+
list(APPEND compat_SOURCES compat/fsmonitor/fsm-settings-win32.c)
317320
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
318321
add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
319322
list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-darwin.c)

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)