Skip to content

Commit 29d28e5

Browse files
jeffhostetlergitster
authored andcommitted
fsmonitor-settings: stub in Win32-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 platform-specific reasons. This commit just creates the framework and adds a stub for Win32. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent abbc910 commit 29d28e5

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

1987+
ifdef FSMONITOR_OS_SETTINGS
1988+
COMPAT_CFLAGS += -DHAVE_FSMONITOR_OS_SETTINGS
1989+
COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_OS_SETTINGS).o
1990+
endif
1991+
19821992
ifeq ($(TCLTK_PATH),)
19831993
NO_TCLTK = NoThanks
19841994
endif
@@ -2901,6 +2911,9 @@ GIT-BUILD-OPTIONS: FORCE
29012911
ifdef FSMONITOR_DAEMON_BACKEND
29022912
@echo FSMONITOR_DAEMON_BACKEND=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_DAEMON_BACKEND)))'\' >>$@+
29032913
endif
2914+
ifdef FSMONITOR_OS_SETTINGS
2915+
@echo FSMONITOR_OS_SETTINGS=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_OS_SETTINGS)))'\' >>$@+
2916+
endif
29042917
ifdef TEST_OUTPUT_DIRECTORY
29052918
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
29062919
endif
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_OK;
9+
}

config.mak.uname

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ ifeq ($(uname_S),Windows)
450450
# These are always available, so we do not have to conditionally
451451
# support it.
452452
FSMONITOR_DAEMON_BACKEND = win32
453+
FSMONITOR_OS_SETTINGS = win32
454+
453455
NO_SVN_TESTS = YesPlease
454456
RUNTIME_PREFIX = YesPlease
455457
HAVE_WPGMPTR = YesWeDo
@@ -639,6 +641,8 @@ ifeq ($(uname_S),MINGW)
639641
# These are always available, so we do not have to conditionally
640642
# support it.
641643
FSMONITOR_DAEMON_BACKEND = win32
644+
FSMONITOR_OS_SETTINGS = win32
645+
642646
RUNTIME_PREFIX = YesPlease
643647
HAVE_WPGMPTR = YesWeDo
644648
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
@@ -289,6 +289,9 @@ if(SUPPORTS_SIMPLE_IPC)
289289
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
290290
add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
291291
list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-win32.c)
292+
293+
add_compile_definitions(HAVE_FSMONITOR_OS_SETTINGS)
294+
list(APPEND compat_SOURCES compat/fsmonitor/fsm-settings-win32.c)
292295
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
293296
add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
294297
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_OK) {
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
@@ -30,4 +30,17 @@ int fsm_settings__error_if_incompatible(struct repository *r);
3030

3131
struct fsmonitor_settings;
3232

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

0 commit comments

Comments
 (0)