var: add config file locations
[git/debian.git] / fsmonitor.h
blobc67e0ebc09bd52bc9cb0b65d054b1d9ef83003e1
1 #ifndef FSMONITOR_H
2 #define FSMONITOR_H
4 #include "cache.h"
5 #include "dir.h"
6 #include "fsmonitor-settings.h"
7 #include "trace.h"
9 extern struct trace_key trace_fsmonitor;
12 * Read the fsmonitor index extension and (if configured) restore the
13 * CE_FSMONITOR_VALID state.
15 int read_fsmonitor_extension(struct index_state *istate, const void *data, unsigned long sz);
18 * Fill the fsmonitor_dirty ewah bits with their state from the index,
19 * before it is split during writing.
21 void fill_fsmonitor_bitmap(struct index_state *istate);
24 * Write the CE_FSMONITOR_VALID state into the fsmonitor index
25 * extension. Reads from the fsmonitor_dirty ewah in the index.
27 void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate);
30 * Add/remove the fsmonitor index extension
32 void add_fsmonitor(struct index_state *istate);
33 void remove_fsmonitor(struct index_state *istate);
36 * Add/remove the fsmonitor index extension as necessary based on the current
37 * core.fsmonitor setting.
39 void tweak_fsmonitor(struct index_state *istate);
42 * Run the configured fsmonitor integration script and clear the
43 * CE_FSMONITOR_VALID bit for any files returned as dirty. Also invalidate
44 * any corresponding untracked cache directory structures. Optimized to only
45 * run the first time it is called.
47 void refresh_fsmonitor(struct index_state *istate);
50 * Does the received result contain the "trivial" response?
52 int fsmonitor_is_trivial_response(const struct strbuf *query_result);
55 * Check if refresh_fsmonitor has been called at least once.
56 * refresh_fsmonitor is idempotent. Returns true if fsmonitor is
57 * not enabled (since the state will be "fresh" w/ CE_FSMONITOR_VALID unset)
58 * This version is useful for assertions
60 static inline int is_fsmonitor_refreshed(const struct index_state *istate)
62 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
64 return fsm_mode <= FSMONITOR_MODE_DISABLED ||
65 istate->fsmonitor_has_run_once;
69 * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
70 * called any time the cache entry has been updated to reflect the
71 * current state of the file on disk.
73 * However, never mark submodules as valid. When commands like "git
74 * status" run they might need to recurse into the submodule (using a
75 * child process) to get a summary of the submodule state. We don't
76 * have (and don't want to create) the facility to translate every
77 * FS event that we receive and that happens to be deep inside of a
78 * submodule back to the submodule root, so we cannot correctly keep
79 * track of this bit on the gitlink directory. Therefore, we never
80 * set it on submodules.
82 static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache_entry *ce)
84 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
86 if (fsm_mode > FSMONITOR_MODE_DISABLED &&
87 !(ce->ce_flags & CE_FSMONITOR_VALID)) {
88 if (S_ISGITLINK(ce->ce_mode))
89 return;
90 istate->cache_changed |= FSMONITOR_CHANGED;
91 ce->ce_flags |= CE_FSMONITOR_VALID;
92 trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name);
97 * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate
98 * any corresponding untracked cache directory structures. This should
99 * be called any time git creates or modifies a file that should
100 * trigger an lstat() or invalidate the untracked cache for the
101 * corresponding directory
103 static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce)
105 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
107 if (fsm_mode > FSMONITOR_MODE_DISABLED) {
108 ce->ce_flags &= ~CE_FSMONITOR_VALID;
109 untracked_cache_invalidate_path(istate, ce->name, 1);
110 trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name);
114 #endif