6 #include "fsmonitor-settings.h"
8 extern struct trace_key trace_fsmonitor
;
11 * Read the fsmonitor index extension and (if configured) restore the
12 * CE_FSMONITOR_VALID state.
14 int read_fsmonitor_extension(struct index_state
*istate
, const void *data
, unsigned long sz
);
17 * Fill the fsmonitor_dirty ewah bits with their state from the index,
18 * before it is split during writing.
20 void fill_fsmonitor_bitmap(struct index_state
*istate
);
23 * Write the CE_FSMONITOR_VALID state into the fsmonitor index
24 * extension. Reads from the fsmonitor_dirty ewah in the index.
26 void write_fsmonitor_extension(struct strbuf
*sb
, struct index_state
*istate
);
29 * Add/remove the fsmonitor index extension
31 void add_fsmonitor(struct index_state
*istate
);
32 void remove_fsmonitor(struct index_state
*istate
);
35 * Add/remove the fsmonitor index extension as necessary based on the current
36 * core.fsmonitor setting.
38 void tweak_fsmonitor(struct index_state
*istate
);
41 * Run the configured fsmonitor integration script and clear the
42 * CE_FSMONITOR_VALID bit for any files returned as dirty. Also invalidate
43 * any corresponding untracked cache directory structures. Optimized to only
44 * run the first time it is called.
46 void refresh_fsmonitor(struct index_state
*istate
);
49 * Does the received result contain the "trivial" response?
51 int fsmonitor_is_trivial_response(const struct strbuf
*query_result
);
54 * Check if refresh_fsmonitor has been called at least once.
55 * refresh_fsmonitor is idempotent. Returns true if fsmonitor is
56 * not enabled (since the state will be "fresh" w/ CE_FSMONITOR_VALID unset)
57 * This version is useful for assertions
59 static inline int is_fsmonitor_refreshed(const struct index_state
*istate
)
61 enum fsmonitor_mode fsm_mode
= fsm_settings__get_mode(istate
->repo
);
63 return fsm_mode
<= FSMONITOR_MODE_DISABLED
||
64 istate
->fsmonitor_has_run_once
;
68 * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
69 * called any time the cache entry has been updated to reflect the
70 * current state of the file on disk.
72 * However, never mark submodules as valid. When commands like "git
73 * status" run they might need to recurse into the submodule (using a
74 * child process) to get a summary of the submodule state. We don't
75 * have (and don't want to create) the facility to translate every
76 * FS event that we receive and that happens to be deep inside of a
77 * submodule back to the submodule root, so we cannot correctly keep
78 * track of this bit on the gitlink directory. Therefore, we never
79 * set it on submodules.
81 static inline void mark_fsmonitor_valid(struct index_state
*istate
, struct cache_entry
*ce
)
83 enum fsmonitor_mode fsm_mode
= fsm_settings__get_mode(istate
->repo
);
85 if (fsm_mode
> FSMONITOR_MODE_DISABLED
&&
86 !(ce
->ce_flags
& CE_FSMONITOR_VALID
)) {
87 if (S_ISGITLINK(ce
->ce_mode
))
89 istate
->cache_changed
= 1;
90 ce
->ce_flags
|= CE_FSMONITOR_VALID
;
91 trace_printf_key(&trace_fsmonitor
, "mark_fsmonitor_clean '%s'", ce
->name
);
96 * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate
97 * any corresponding untracked cache directory structures. This should
98 * be called any time git creates or modifies a file that should
99 * trigger an lstat() or invalidate the untracked cache for the
100 * corresponding directory
102 static inline void mark_fsmonitor_invalid(struct index_state
*istate
, struct cache_entry
*ce
)
104 enum fsmonitor_mode fsm_mode
= fsm_settings__get_mode(istate
->repo
);
106 if (fsm_mode
> FSMONITOR_MODE_DISABLED
) {
107 ce
->ce_flags
&= ~CE_FSMONITOR_VALID
;
108 untracked_cache_invalidate_path(istate
, ce
->name
, 1);
109 trace_printf_key(&trace_fsmonitor
, "mark_fsmonitor_invalid '%s'", ce
->name
);