config: FSMonitor is repository-specific

This commit refactors `git_config_get_fsmonitor()` into the `repo_*()`
form that takes a parameter `struct repository *r`.

That change prepares for the upcoming `core.useBuiltinFSMonitor` flag which
will be stored in the `repo_settings` struct.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2021-03-05 21:20:26 +01:00
parent 81fb7fdbe3
commit 7a905fca60
4 changed files with 6 additions and 6 deletions

View File

@@ -1216,14 +1216,14 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
}
if (fsmonitor > 0) {
if (git_config_get_fsmonitor() == 0)
if (repo_config_get_fsmonitor(r) == 0)
warning(_("core.fsmonitor is unset; "
"set it if you really want to "
"enable fsmonitor"));
add_fsmonitor(&the_index);
report(_("fsmonitor enabled"));
} else if (!fsmonitor) {
if (git_config_get_fsmonitor() == 1)
if (repo_config_get_fsmonitor(r) == 1)
warning(_("core.fsmonitor is set; "
"remove it if you really want to "
"disable fsmonitor"));

View File

@@ -2516,9 +2516,9 @@ int git_config_get_max_percent_split_change(void)
return -1; /* default value */
}
int git_config_get_fsmonitor(void)
int repo_config_get_fsmonitor(struct repository *r)
{
if (git_config_get_pathname("core.fsmonitor", &core_fsmonitor))
if (repo_config_get_pathname(r, "core.fsmonitor", &core_fsmonitor))
core_fsmonitor = getenv("GIT_TEST_FSMONITOR");
if (core_fsmonitor && !*core_fsmonitor)

View File

@@ -609,7 +609,7 @@ int git_config_get_index_threads(int *dest);
int git_config_get_untracked_cache(void);
int git_config_get_split_index(void);
int git_config_get_max_percent_split_change(void);
int git_config_get_fsmonitor(void);
int repo_config_get_fsmonitor(struct repository *r);
/* This dies if the configured or default date is in the future */
int git_config_get_expiry(const char *key, const char **output);

View File

@@ -411,7 +411,7 @@ void remove_fsmonitor(struct index_state *istate)
void tweak_fsmonitor(struct index_state *istate)
{
unsigned int i;
int fsmonitor_enabled = git_config_get_fsmonitor();
int fsmonitor_enabled = repo_config_get_fsmonitor(istate->repo ? istate->repo : the_repository);
if (istate->fsmonitor_dirty) {
if (fsmonitor_enabled) {