1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-01 01:56:10 +02:00

fsmonitor: reintroduce core.useBuiltinFSMonitor

Reintroduce the 'core.useBuiltinFSMonitor' config setting (originally added
in 0a756b2a25 (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 <vdye@github.com>
This commit is contained in:
Victoria Dye 2022-04-04 15:38:58 -07:00 committed by Johannes Schindelin
parent baacc7531e
commit 82a3f2b47e
4 changed files with 38 additions and 2 deletions

View File

@ -154,4 +154,8 @@ advice.*::
Shown when the user tries to create a worktree from an
invalid reference, to tell the user how to create a new unborn
branch instead.
useCoreFSMonitorConfig::
Advice shown if the deprecated 'core.useBuiltinFSMonitor' config
setting is in use.
--

View File

@ -84,6 +84,7 @@ static struct {
[ADVICE_SUBMODULE_MERGE_CONFLICT] = { "submoduleMergeConflict" },
[ADVICE_SUGGEST_DETACHING_HEAD] = { "suggestDetachingHead" },
[ADVICE_UPDATE_SPARSE_PATH] = { "updateSparsePath" },
[ADVICE_USE_CORE_FSMONITOR_CONFIG] = { "useCoreFSMonitorConfig" },
[ADVICE_WAITING_FOR_EDITOR] = { "waitingForEditor" },
[ADVICE_WORKTREE_ADD_ORPHAN] = { "worktreeAddOrphan" },
};

View File

@ -52,6 +52,7 @@ enum advice_type {
ADVICE_SUBMODULE_MERGE_CONFLICT,
ADVICE_SUGGEST_DETACHING_HEAD,
ADVICE_UPDATE_SPARSE_PATH,
ADVICE_USE_CORE_FSMONITOR_CONFIG,
ADVICE_WAITING_FOR_EDITOR,
ADVICE_WORKTREE_ADD_ORPHAN,
};

View File

@ -5,6 +5,7 @@
#include "fsmonitor-ipc.h"
#include "fsmonitor-settings.h"
#include "fsmonitor-path-utils.h"
#include "advice.h"
/*
* We keep this structure defintion private and have getters
@ -100,6 +101,31 @@ static struct fsmonitor_settings *alloc_settings(void)
return s;
}
static int check_deprecated_builtin_config(struct repository *r)
{
int core_use_builtin_fsmonitor = 0;
/*
* If 'core.useBuiltinFSMonitor' is set, print a deprecation warning
* suggesting the use of 'core.fsmonitor' instead. If the config is
* set to true, set the appropriate mode and return 1 indicating that
* the check resulted the config being set by this (deprecated) setting.
*/
if(!repo_config_get_bool(r, "core.useBuiltinFSMonitor", &core_use_builtin_fsmonitor) &&
core_use_builtin_fsmonitor) {
if (!git_env_bool("GIT_SUPPRESS_USEBUILTINFSMONITOR_ADVICE", 0)) {
advise_if_enabled(ADVICE_USE_CORE_FSMONITOR_CONFIG,
_("core.useBuiltinFSMonitor=true is deprecated;"
"please set core.fsmonitor=true instead"));
setenv("GIT_SUPPRESS_USEBUILTINFSMONITOR_ADVICE", "1", 1);
}
fsm_settings__set_ipc(r);
return 1;
}
return 0;
}
static void lookup_fsmonitor_settings(struct repository *r)
{
const char *const_str;
@ -125,12 +151,16 @@ static void lookup_fsmonitor_settings(struct repository *r)
return;
case 1: /* config value was unset */
if (check_deprecated_builtin_config(r))
return;
const_str = getenv("GIT_TEST_FSMONITOR");
break;
case -1: /* config value set to an arbitrary string */
if (repo_config_get_pathname(r, "core.fsmonitor", &const_str))
return; /* should not happen */
if (check_deprecated_builtin_config(r) ||
repo_config_get_pathname(r, "core.fsmonitor", &const_str))
return;
break;
default: /* should not happen */