Skip to content

Commit fec4962

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 9fffee1 commit fec4962

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
@@ -136,4 +136,7 @@ advice.*::
136136
Advice shown when either linkgit:git-add[1] or linkgit:git-rm[1]
137137
is asked to update index entries outside the current sparse
138138
checkout.
139+
useCoreFSMonitorConfig::
140+
Advice shown if the deprecated 'core.useBuiltinFSMonitor' config
141+
setting is in use.
139142
--

advice.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static struct {
7474
[ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE] = { "submoduleAlternateErrorStrategyDie", 1 },
7575
[ADVICE_SUBMODULES_NOT_UPDATED] = { "submodulesNotUpdated", 1 },
7676
[ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath", 1 },
77+
[ADVICE_USE_CORE_FSMONITOR_CONFIG] = { "useCoreFSMonitorConfig", 1 },
7778
[ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor", 1 },
7879
};
7980

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct string_list;
4848
ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE,
4949
ADVICE_SUBMODULES_NOT_UPDATED,
5050
ADVICE_UPDATE_SPARSE_PATH,
51+
ADVICE_USE_CORE_FSMONITOR_CONFIG,
5152
ADVICE_WAITING_FOR_EDITOR,
5253
ADVICE_SKIPPED_CHERRY_PICKS,
5354
};

fsmonitor-settings.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,31 @@ static int check_for_incompatible(struct repository *r)
4848
return 0;
4949
}
5050

51+
static int check_deprecated_builtin_config(struct repository *r)
52+
{
53+
int core_use_builtin_fsmonitor = 0;
54+
55+
/*
56+
* If 'core.useBuiltinFSMonitor' is set, print a deprecation warning
57+
* suggesting the use of 'core.fsmonitor' instead. If the config is
58+
* set to true, set the appropriate mode and return 1 indicating that
59+
* the check resulted the config being set by this (deprecated) setting.
60+
*/
61+
if(!repo_config_get_bool(r, "core.useBuiltinFSMonitor", &core_use_builtin_fsmonitor) &&
62+
core_use_builtin_fsmonitor) {
63+
if (!git_env_bool("GIT_SUPPRESS_USEBUILTINFSMONITOR_ADVICE", 0)) {
64+
advise_if_enabled(ADVICE_USE_CORE_FSMONITOR_CONFIG,
65+
_("core.useBuiltinFSMonitor=true is deprecated;"
66+
"please set core.fsmonitor=true instead"));
67+
setenv("GIT_SUPPRESS_USEBUILTINFSMONITOR_ADVICE", "1", 1);
68+
}
69+
fsm_settings__set_ipc(r);
70+
return 1;
71+
}
72+
73+
return 0;
74+
}
75+
5176
static void lookup_fsmonitor_settings(struct repository *r)
5277
{
5378
struct fsmonitor_settings *s;
@@ -78,12 +103,16 @@ static void lookup_fsmonitor_settings(struct repository *r)
78103
return;
79104

80105
case 1: /* config value was unset */
106+
if (check_deprecated_builtin_config(r))
107+
return;
108+
81109
const_str = getenv("GIT_TEST_FSMONITOR");
82110
break;
83111

84112
case -1: /* config value set to an arbitrary string */
85-
if (repo_config_get_pathname(r, "core.fsmonitor", &const_str))
86-
return; /* should not happen */
113+
if (check_deprecated_builtin_config(r) ||
114+
repo_config_get_pathname(r, "core.fsmonitor", &const_str))
115+
return;
87116
break;
88117

89118
default: /* should not happen */

0 commit comments

Comments
 (0)