Skip to content

Commit 75ed85d

Browse files
dschomjcheetham
authored andcommitted
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 69aeeee + e890ff3 commit 75ed85d

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

Documentation/config/advice.txt

+3
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,7 @@ advice.*::
141141
checkout.
142142
diverging::
143143
Advice shown when a fast-forward is not possible.
144+
useCoreFSMonitorConfig::
145+
Advice shown if the deprecated 'core.useBuiltinFSMonitor' config
146+
setting is in use.
144147
--

advice.c

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static struct {
7878
[ADVICE_SUBMODULE_ALTERNATE_ERROR_STRATEGY_DIE] = { "submoduleAlternateErrorStrategyDie", 1 },
7979
[ADVICE_SUBMODULES_NOT_UPDATED] = { "submodulesNotUpdated", 1 },
8080
[ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath", 1 },
81+
[ADVICE_USE_CORE_FSMONITOR_CONFIG] = { "useCoreFSMonitorConfig", 1 },
8182
[ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor", 1 },
8283
};
8384

advice.h

+1
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

+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 defintion private and have getters
@@ -99,6 +100,31 @@ static struct fsmonitor_settings *alloc_settings(void)
99100
return s;
100101
}
101102

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

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

130159
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 */
160+
if (check_deprecated_builtin_config(r) ||
161+
repo_config_get_pathname(r, "core.fsmonitor", &const_str))
162+
return;
133163
break;
134164

135165
default: /* should not happen */

0 commit comments

Comments
 (0)