diff --git a/builtin/fetch.c b/builtin/fetch.c index ab7db2be06d14c..2792d5ba6157fe 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -2649,6 +2649,7 @@ int cmd_fetch(int argc, if (the_repository->gitdir) { prepare_repo_settings(the_repository); the_repository->settings.command_requires_full_index = 0; + the_repository->settings.command_requires_fsmonitor = 0; } argc = parse_options(argc, argv, prefix, diff --git a/fsmonitor.c b/fsmonitor.c index 107767527ebec7..f8dc740e5a3586 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -792,7 +792,8 @@ void remove_fsmonitor(struct index_state *istate) void tweak_fsmonitor(struct index_state *istate) { unsigned int i; - int fsmonitor_enabled = (fsm_settings__get_mode(istate->repo) + int fsmonitor_enabled = (istate->repo->settings.command_requires_fsmonitor && + fsm_settings__get_mode(istate->repo) > FSMONITOR_MODE_DISABLED); if (istate->fsmonitor_dirty) { diff --git a/repo-settings.c b/repo-settings.c index f3be3b8c5a3d09..a58d7778c0c87e 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -138,6 +138,7 @@ void prepare_repo_settings(struct repository *r) * removed. */ r->settings.command_requires_full_index = 1; + r->settings.command_requires_fsmonitor = 1; if (!repo_config_get_ulong(r, "core.deltabasecachelimit", &ulongval)) r->settings.delta_base_cache_limit = ulongval; diff --git a/repo-settings.h b/repo-settings.h index e5253ead025c83..695e3e5c0a9de4 100644 --- a/repo-settings.h +++ b/repo-settings.h @@ -25,6 +25,7 @@ struct repo_settings { int gc_write_commit_graph; int fetch_write_commit_graph; int command_requires_full_index; + int command_requires_fsmonitor; int sparse_index; int pack_read_reverse_index; int pack_use_bitmap_boundary_traversal; diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 93973ed25a448b..e80a8e501d4951 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -477,4 +477,25 @@ test_expect_success 'status succeeds with sparse index' ' ) ' +test_expect_success "fetch does not activate fsmonitor" ' + test_when_finished "rm -rf fsm-repo fsm-upstream" && + + git init fsm-upstream && + test_commit -C fsm-upstream initial && + + git clone fsm-upstream fsm-repo && + test_hook -C fsm-repo fsmonitor-test <<-\EOF && + printf "last_update_token\0" + EOF + git -C fsm-repo config core.fsmonitor .git/hooks/fsmonitor-test && + + GIT_TRACE2_EVENT="$(pwd)/trace2-status.txt" \ + git -C fsm-repo status && + test_region fsm_hook query trace2-status.txt && + + GIT_TRACE2_EVENT="$(pwd)/trace2-fetch.txt" \ + git -C fsm-repo fetch origin && + test_region ! fsm_hook query trace2-fetch.txt +' + test_done