From bcb02d306885bfdeb9efb63647c24eee56bd9fe8 Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Tue, 5 Apr 2022 13:42:23 -0700 Subject: [PATCH] scalar: upgrade to newest FSMonitor config setting When FSMonitor was upstreamed, the 'core.useBuiltinFSMonitor' config was deprecated and replaced with an overload of the 'core.fsmonitor' config (i.e., if a boolean value was specified in 'core.fsmonitor', it is treated the way 'core.useBuiltinFSMonitor' originally was). Because 'scalar register' actively sets that config, use it to upgrade the deprecated config setting. Co-authored-by: Johannes Schindelin Signed-off-by: Victoria Dye --- scalar.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scalar.c b/scalar.c index 0ad480396fdcc1..be9e8e100e26af 100644 --- a/scalar.c +++ b/scalar.c @@ -194,6 +194,23 @@ static int set_recommended_config(int reconfigure) int i; char *value; + /* + * If a user has "core.usebuiltinfsmonitor" enabled, try to switch to + * the new (non-deprecated) setting (core.fsmonitor). + */ + if (!git_config_get_string("core.usebuiltinfsmonitor", &value)) { + char *dummy = NULL; + if (git_config_get_string("core.fsmonitor", &dummy) && + git_config_set_gently("core.fsmonitor", value) < 0) + return error(_("could not configure %s=%s"), + "core.fsmonitor", value); + if (git_config_set_gently("core.usebuiltinfsmonitor", NULL) < 0) + return error(_("could not configure %s=%s"), + "core.useBuiltinFSMonitor", "NULL"); + free(value); + free(dummy); + } + for (i = 0; config[i].key; i++) { if ((reconfigure && config[i].overwrite_on_reconfigure) || git_config_get_string(config[i].key, &value)) {