Skip to content

Commit 255b3cc

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 9081a08 + 0df1f50 commit 255b3cc

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

Documentation/config/advice.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,8 @@ all advice messages.
169169
Shown when the user tries to create a worktree from an
170170
invalid reference, to tell the user how to create a new unborn
171171
branch instead.
172+
173+
useCoreFSMonitorConfig::
174+
Advice shown if the deprecated 'core.useBuiltinFSMonitor' config
175+
setting is in use.
172176
--

advice.c

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static struct {
8989
[ADVICE_SUBMODULE_MERGE_CONFLICT] = { "submoduleMergeConflict" },
9090
[ADVICE_SUGGEST_DETACHING_HEAD] = { "suggestDetachingHead" },
9191
[ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath" },
92+
[ADVICE_USE_CORE_FSMONITOR_CONFIG] = { "useCoreFSMonitorConfig" },
9293
[ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor" },
9394
[ADVICE_WORKTREE_ADD_ORPHAN] = { "worktreeAddOrphan" },
9495
};

advice.h

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum advice_type {
5656
ADVICE_SUBMODULE_MERGE_CONFLICT,
5757
ADVICE_SUGGEST_DETACHING_HEAD,
5858
ADVICE_UPDATE_SPARSE_PATH,
59+
ADVICE_USE_CORE_FSMONITOR_CONFIG,
5960
ADVICE_WAITING_FOR_EDITOR,
6061
ADVICE_WORKTREE_ADD_ORPHAN,
6162
};

fsmonitor-settings.c

+32-2
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 definition 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;
@@ -126,12 +152,16 @@ static void lookup_fsmonitor_settings(struct repository *r)
126152
return;
127153

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

132161
case -1: /* config value set to an arbitrary string */
133-
if (repo_config_get_pathname(r, "core.fsmonitor", &to_free))
134-
return; /* should not happen */
162+
if (check_deprecated_builtin_config(r) ||
163+
repo_config_get_pathname(r, "core.fsmonitor", &to_free))
164+
return;
135165
const_str = to_free;
136166
break;
137167

0 commit comments

Comments
 (0)