From ca7feca3dc2fa93b9c5ff2cb672e54f6f9f11a1f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 5 Mar 2021 23:12:11 +0100 Subject: [PATCH] Enable the built-in FSMonitor as an experimental feature If `feature.experimental` and `feature.manyFiles` are set and the user has not explicitly turned off the builtin FSMonitor, we now start the built-in FSMonitor by default. Only forcing it when UNSET matches the behavior of UPDATE_DEFAULT_BOOL() used for other repo settings. Signed-off-by: Johannes Schindelin Signed-off-by: Jeff Hostetler --- repo-settings.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/repo-settings.c b/repo-settings.c index 08c60a9274..5241a9b4a0 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -2,13 +2,14 @@ #include "config.h" #include "repository.h" #include "midx.h" -#include "compat/fsmonitor/fsm-listen.h" +#include "fsmonitor-ipc.h" +#include "fsmonitor-settings.h" #define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0) void prepare_repo_settings(struct repository *r) { - int value; + int value, feature_many_files = 0; char *strval; if (r->settings.initialized) @@ -62,6 +63,7 @@ void prepare_repo_settings(struct repository *r) UPDATE_DEFAULT_BOOL(r->settings.core_multi_pack_index, 1); if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) { + feature_many_files = 1; UPDATE_DEFAULT_BOOL(r->settings.index_version, 4); UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE); } @@ -70,9 +72,33 @@ void prepare_repo_settings(struct repository *r) r->settings.fetch_write_commit_graph = value; UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 0); - if (!repo_config_get_bool(r, "feature.experimental", &value) && value) + if (!repo_config_get_bool(r, "feature.experimental", &value) && value) { UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING); + /* + * Force enable the builtin FSMonitor (unless the repo + * is incompatible or they've already selected it or + * the hook version). But only if they haven't + * explicitly turned it off -- so only if our config + * value is UNSET. + * + * lookup_fsmonitor_settings() and check_for_ipc() do + * not distinguish between explicitly set FALSE and + * UNSET, so we re-test for an UNSET config key here. + * + * I'm not sure I want to fix fsmonitor-settings.c to + * have more than one _DISABLED state since our usage + * here is only to support this experimental period + * (and I don't want to overload the _reason field + * because it describes incompabilities). + */ + if (feature_many_files && + fsmonitor_ipc__is_supported() && + fsm_settings__get_mode(r) == FSMONITOR_MODE_DISABLED && + repo_config_get_bool(r, "core.usebuiltinfsmonitor", &value)) + fsm_settings__set_ipc(r); + } + /* Hack for test programs like test-dump-untracked-cache */ if (ignore_untracked_cache_config) r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;