Skip to content

Commit 33897e3

Browse files
jeffhostetlerGit for Windows Build Agent
authored andcommitted
Merge branch 'mark-v4-fsmonitor-experimental' into try-v4-fsmonitor
2 parents 3395e0e + a142a2e commit 33897e3

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
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
@@ -47,6 +47,31 @@ static struct fsmonitor_settings *alloc_settings(void)
4747
return s;
4848
}
4949

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

7499
case 1: /* config value was unset */
100+
if (check_deprecated_builtin_config(r))
101+
return;
102+
75103
const_str = getenv("GIT_TEST_FSMONITOR");
76104
break;
77105

78106
case -1: /* config value set to an arbitrary string */
79-
if (repo_config_get_pathname(r, "core.fsmonitor", &const_str))
80-
return; /* should not happen */
107+
if (check_deprecated_builtin_config(r) ||
108+
repo_config_get_pathname(r, "core.fsmonitor", &const_str))
109+
return;
81110
break;
82111

83112
default: /* should not happen */

repo-settings.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#include "config.h"
33
#include "repository.h"
44
#include "midx.h"
5-
#include "compat/fsmonitor/fsm-listen.h"
5+
#include "fsmonitor-ipc.h"
6+
#include "fsmonitor-settings.h"
67

78
static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
89
int def)
@@ -36,6 +37,30 @@ void prepare_repo_settings(struct repository *r)
3637
/* Defaults modified by feature.* */
3738
if (experimental) {
3839
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
40+
41+
/*
42+
* Force enable the builtin FSMonitor (unless the repo
43+
* is incompatible or they've already selected it or
44+
* the hook version). But only if they haven't
45+
* explicitly turned it off -- so only if our config
46+
* value is UNSET.
47+
*
48+
* lookup_fsmonitor_settings() and check_for_ipc() do
49+
* not distinguish between explicitly set FALSE and
50+
* UNSET, so we re-test for an UNSET config key here.
51+
*
52+
* I'm not sure I want to fix fsmonitor-settings.c to
53+
* have more than one _DISABLED state since our usage
54+
* here is only to support this experimental period
55+
* (and I don't want to overload the _reason field
56+
* because it describes incompabilities).
57+
*/
58+
if (manyfiles &&
59+
fsmonitor_ipc__is_supported() &&
60+
fsm_settings__get_mode(r) == FSMONITOR_MODE_DISABLED &&
61+
repo_config_get_maybe_bool(r, "core.fsmonitor", &value) > 0 &&
62+
repo_config_get_bool(r, "core.useBuiltinFSMonitor", &value))
63+
fsm_settings__set_ipc(r);
3964
}
4065
if (manyfiles) {
4166
r->settings.index_version = 4;

0 commit comments

Comments
 (0)