@@ -339,7 +339,8 @@ struct index_state {
struct cache_time timestamp;
unsigned name_hash_initialized : 1,
initialized : 1,
- drop_cache_tree : 1;
+ drop_cache_tree : 1,
+ fsmonitor_has_run_once : 1;
struct hashmap name_hash;
struct hashmap dir_hash;
struct object_id oid;
@@ -129,7 +129,6 @@ static void fsmonitor_refresh_callback(struct index_state *istate, const char *n
void refresh_fsmonitor(struct index_state *istate)
{
- static int has_run_once = 0;
struct strbuf query_result = STRBUF_INIT;
int query_success = 0;
size_t bol; /* beginning of line */
@@ -137,9 +136,9 @@ void refresh_fsmonitor(struct index_state *istate)
char *buf;
int i;
- if (!core_fsmonitor || has_run_once)
+ if (!core_fsmonitor || istate->fsmonitor_has_run_once)
return;
- has_run_once = 1;
+ istate->fsmonitor_has_run_once = 1;
trace_printf_key(&trace_fsmonitor, "refresh fsmonitor");
/*
@@ -2335,6 +2335,7 @@ int discard_index(struct index_state *istate)
free_name_hash(istate);
cache_tree_free(&(istate->cache_tree));
istate->initialized = 0;
+ istate->fsmonitor_has_run_once = 0;
FREE_AND_NULL(istate->cache);
istate->cache_alloc = 0;
discard_split_index(istate);
@@ -346,7 +346,7 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR'
test_cmp before after
'
-test_expect_failure 'discard_index() also discards fsmonitor info' '
+test_expect_success 'discard_index() also discards fsmonitor info' '
test_when_finished \
"git config core.monitor .git/hooks/fsmonitor-test" &&
test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" &&