Skip to content

Commit f655878

Browse files
vdyedscho
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 7ddb66d commit f655878

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

Documentation/config/advice.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,7 @@ advice.*::
138138
checkout.
139139
diverging::
140140
Advice shown when a fast-forward is not possible.
141+
useCoreFSMonitorConfig::
142+
Advice shown if the deprecated 'core.useBuiltinFSMonitor' config
143+
setting is in use.
141144
--

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
};
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
};

fsmonitor-settings.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,31 @@ static struct fsmonitor_settings *alloc_settings(void)
9999
return s;
100100
}
101101

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

126151
case 1: /* config value was unset */
152+
if (check_deprecated_builtin_config(r))
153+
return;
154+
127155
const_str = getenv("GIT_TEST_FSMONITOR");
128156
break;
129157

130158
case -1: /* config value set to an arbitrary string */
131-
if (repo_config_get_pathname(r, "core.fsmonitor", &const_str))
132-
return; /* should not happen */
159+
if (check_deprecated_builtin_config(r) ||
160+
repo_config_get_pathname(r, "core.fsmonitor", &const_str))
161+
return;
133162
break;
134163

135164
default: /* should not happen */

0 commit comments

Comments
 (0)