Skip to content

Commit 2345937

Browse files
committed
Merge branch 'deprecate-core.useBuiltinFSMonitor'
Originally introduced as `core.useBuiltinFSMonitor` in Git for Windows and developed, improved and stabilized there, the built-in FSMonitor only made it into upstream Git (after unnecessarily long hemming and hawing and throwing overly perfectionist style review sticks into the spokes) as `core.fsmonitor = true`. In Git for Windows, with this topic branch, we re-introduce the now-obsolete config setting, with warnings suggesting to existing users how to switch to the new config setting, with the intention to ultimately drop the patch at some stage. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents cafea19 + 4735523 commit 2345937

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

Documentation/config/advice.txt

+3
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,7 @@ advice.*::
139139
Advice shown when either linkgit:git-add[1] or linkgit:git-rm[1]
140140
is asked to update index entries outside the current sparse
141141
checkout.
142+
useCoreFSMonitorConfig::
143+
Advice shown if the deprecated 'core.useBuiltinFSMonitor' config
144+
setting is in use.
142145
--

advice.c

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static struct {
7575
[ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE] = { "submoduleAlternateErrorStrategyDie", 1 },
7676
[ADVICE_SUBMODULES_NOT_UPDATED] = { "submodulesNotUpdated", 1 },
7777
[ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath", 1 },
78+
[ADVICE_USE_CORE_FSMONITOR_CONFIG] = { "useCoreFSMonitorConfig", 1 },
7879
[ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor", 1 },
7980
};
8081

advice.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct string_list;
4949
ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE,
5050
ADVICE_SUBMODULES_NOT_UPDATED,
5151
ADVICE_UPDATE_SPARSE_PATH,
52+
ADVICE_USE_CORE_FSMONITOR_CONFIG,
5253
ADVICE_WAITING_FOR_EDITOR,
5354
ADVICE_SKIPPED_CHERRY_PICKS,
5455
};

fsmonitor-settings.c

+31-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,31 @@ static struct fsmonitor_settings *alloc_settings(void)
9898
return s;
9999
}
100100

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

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

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

134163
default: /* should not happen */

0 commit comments

Comments
 (0)