fsmonitor: only enable it in non-bare repositories

The entire point of the FSMonitor is to monitor the worktree changes in
a more efficient manner than `lstat()`ing all worktree files every time
we refresh the index.

But if there is no worktree, FSMonitor has nothing to monitor.

So let's ignore if an FSMonitor is configured (e.g. in `~/.gitconfig`)
and we're running in a repository without worktree.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2021-04-28 22:45:38 +02:00
parent 69cb641bc3
commit 8dc7e5e32f

View File

@@ -2519,6 +2519,12 @@ int git_config_get_max_percent_split_change(void)
int repo_config_get_fsmonitor(struct repository *r)
{
if (!r->worktree) {
/* FSMonitor makes no sense in bare repositories */
core_fsmonitor = NULL;
return 1;
}
if (r->settings.use_builtin_fsmonitor > 0) {
core_fsmonitor = "(built-in daemon)";
return 1;