From: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> Bare repos do not have a working directory, so there is no directory for the daemon to register a watch upon. And therefore there are no files within the directory for it to actually watch. Signed-off-by: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> --- builtin/fsmonitor--daemon.c | 8 ++++++++ t/t7519-status-fsmonitor.sh | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c index 7fcf960652f..d6161ad95a5 100644 --- a/builtin/fsmonitor--daemon.c +++ b/builtin/fsmonitor--daemon.c @@ -490,6 +490,14 @@ int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix) die(_("invalid 'ipc-threads' value (%d)"), fsmonitor__ipc_threads); + prepare_repo_settings(the_repository); + if (!the_repository->worktree) + return error(_("fsmonitor-daemon does not support bare repos '%s'"), + xgetcwd()); + if (the_repository->settings.fsmonitor_mode == FSMONITOR_MODE_INCOMPATIBLE) + return error(_("fsmonitor-daemon is incompatible with this repo '%s'"), + the_repository->worktree); + if (!strcmp(subcmd, "start")) return !!try_to_start_background_daemon(); diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 02919c68ddd..ed20a4f7fb9 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -394,6 +394,22 @@ test_expect_success 'incompatible bare repo' ' test_cmp expect actual ' +test_expect_success FSMONITOR_DAEMON 'try running fsmonitor-daemon in bare repo' ' + test_when_finished "rm -rf ./bare-clone" && + git clone --bare . ./bare-clone && + test_must_fail git -C ./bare-clone fsmonitor--daemon run 2>actual && + grep "fsmonitor-daemon does not support bare repos" actual +' + +test_expect_success FSMONITOR_DAEMON 'try running fsmonitor-daemon in virtual repo' ' + test_when_finished "rm -rf ./fake-virtual-clone" && + git clone . ./fake-virtual-clone && + test_must_fail git -C ./fake-virtual-clone \ + -c core.virtualfilesystem=true \ + fsmonitor--daemon run 2>actual && + grep "fsmonitor-daemon is incompatible with this repo" actual +' + test_expect_success 'incompatible core.virtualfilesystem' ' test_when_finished "rm -rf ./fake-gvfs-clone" && git clone . ./fake-gvfs-clone && -- gitgitgadget