Skip to content

Commit 61f6d4a

Browse files
vdyeGit for Windows Build Agent
authored andcommitted
fsmonitor: reintroduce core.useBuiltinFSMonitor
Reintroduce the 'core.useBuiltinFSMonitor' config setting (originally added in 0a756b2 (fsmonitor: config settings are repository-specific, 2021-03-05)) after its removal from the upstream version of FSMonitor. Upstream, the 'core.useBuiltinFSMonitor' setting was rendered obsolete by "overloading" the 'core.fsmonitor' setting to take a boolean value. However, several applications (e.g., 'scalar') utilize the original config setting, so it should be preserved for a deprecation period before complete removal: * if 'core.fsmonitor' is a boolean, the user is correctly using the new config syntax; do not use 'core.useBuiltinFSMonitor'. * if 'core.fsmonitor' is unspecified, use 'core.useBuiltinFSMonitor'. * if 'core.fsmonitor' is a path, override and use the builtin FSMonitor if 'core.useBuiltinFSMonitor' is 'true'; otherwise, use the FSMonitor hook indicated by the path. Additionally, for this deprecation period, advise users to switch to using 'core.fsmonitor' to specify their use of the builtin FSMonitor. Signed-off-by: Victoria Dye <[email protected]>
1 parent 07764c1 commit 61f6d4a

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

Documentation/config/advice.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,8 @@ advice.*::
142142
Advice shown when a user tries to create a worktree from an
143143
invalid reference, to instruct how to create a new orphan
144144
branch instead.
145+
146+
useCoreFSMonitorConfig::
147+
Advice shown if the deprecated 'core.useBuiltinFSMonitor' config
148+
setting is in use.
145149
--

advice.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static struct {
7777
[ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE] = { "submoduleAlternateErrorStrategyDie", 1 },
7878
[ADVICE_SUBMODULES_NOT_UPDATED] = { "submodulesNotUpdated", 1 },
7979
[ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath", 1 },
80+
[ADVICE_USE_CORE_FSMONITOR_CONFIG] = { "useCoreFSMonitorConfig", 1 },
8081
[ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor", 1 },
8182
[ADVICE_WORKTREE_ADD_ORPHAN] = { "worktreeAddOrphan", 1 },
8283
};

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct string_list;
4747
ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE,
4848
ADVICE_SUBMODULES_NOT_UPDATED,
4949
ADVICE_UPDATE_SPARSE_PATH,
50+
ADVICE_USE_CORE_FSMONITOR_CONFIG,
5051
ADVICE_WAITING_FOR_EDITOR,
5152
ADVICE_SKIPPED_CHERRY_PICKS,
5253
ADVICE_WORKTREE_ADD_ORPHAN,

fsmonitor-settings.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "fsmonitor-ipc.h"
66
#include "fsmonitor-settings.h"
77
#include "fsmonitor-path-utils.h"
8+
#include "advice.h"
89

910
/*
1011
* We keep this structure defintion private and have getters
@@ -100,6 +101,31 @@ static struct fsmonitor_settings *alloc_settings(void)
100101
return s;
101102
}
102103

104+
static int check_deprecated_builtin_config(struct repository *r)
105+
{
106+
int core_use_builtin_fsmonitor = 0;
107+
108+
/*
109+
* If 'core.useBuiltinFSMonitor' is set, print a deprecation warning
110+
* suggesting the use of 'core.fsmonitor' instead. If the config is
111+
* set to true, set the appropriate mode and return 1 indicating that
112+
* the check resulted the config being set by this (deprecated) setting.
113+
*/
114+
if(!repo_config_get_bool(r, "core.useBuiltinFSMonitor", &core_use_builtin_fsmonitor) &&
115+
core_use_builtin_fsmonitor) {
116+
if (!git_env_bool("GIT_SUPPRESS_USEBUILTINFSMONITOR_ADVICE", 0)) {
117+
advise_if_enabled(ADVICE_USE_CORE_FSMONITOR_CONFIG,
118+
_("core.useBuiltinFSMonitor=true is deprecated;"
119+
"please set core.fsmonitor=true instead"));
120+
setenv("GIT_SUPPRESS_USEBUILTINFSMONITOR_ADVICE", "1", 1);
121+
}
122+
fsm_settings__set_ipc(r);
123+
return 1;
124+
}
125+
126+
return 0;
127+
}
128+
103129
static void lookup_fsmonitor_settings(struct repository *r)
104130
{
105131
const char *const_str;
@@ -125,12 +151,16 @@ static void lookup_fsmonitor_settings(struct repository *r)
125151
return;
126152

127153
case 1: /* config value was unset */
154+
if (check_deprecated_builtin_config(r))
155+
return;
156+
128157
const_str = getenv("GIT_TEST_FSMONITOR");
129158
break;
130159

131160
case -1: /* config value set to an arbitrary string */
132-
if (repo_config_get_pathname(r, "core.fsmonitor", &const_str))
133-
return; /* should not happen */
161+
if (check_deprecated_builtin_config(r) ||
162+
repo_config_get_pathname(r, "core.fsmonitor", &const_str))
163+
return;
134164
break;
135165

136166
default: /* should not happen */

0 commit comments

Comments
 (0)