Merge branch 'js/win32-retry-pipe-write-on-enospc' into maint-2.43
[alt-git.git] / fsmonitor.h
blob5195a8624db82b27f8fbb533675b35e841a2a44b
1 #ifndef FSMONITOR_H
2 #define FSMONITOR_H
4 #include "fsmonitor-ll.h"
5 #include "dir.h"
6 #include "fsmonitor-settings.h"
7 #include "object.h"
8 #include "read-cache-ll.h"
9 #include "trace.h"
12 * Check if refresh_fsmonitor has been called at least once.
13 * refresh_fsmonitor is idempotent. Returns true if fsmonitor is
14 * not enabled (since the state will be "fresh" w/ CE_FSMONITOR_VALID unset)
15 * This version is useful for assertions
17 static inline int is_fsmonitor_refreshed(const struct index_state *istate)
19 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
21 return fsm_mode <= FSMONITOR_MODE_DISABLED ||
22 istate->fsmonitor_has_run_once;
26 * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
27 * called any time the cache entry has been updated to reflect the
28 * current state of the file on disk.
30 * However, never mark submodules as valid. When commands like "git
31 * status" run they might need to recurse into the submodule (using a
32 * child process) to get a summary of the submodule state. We don't
33 * have (and don't want to create) the facility to translate every
34 * FS event that we receive and that happens to be deep inside of a
35 * submodule back to the submodule root, so we cannot correctly keep
36 * track of this bit on the gitlink directory. Therefore, we never
37 * set it on submodules.
39 static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache_entry *ce)
41 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
43 if (fsm_mode > FSMONITOR_MODE_DISABLED &&
44 !(ce->ce_flags & CE_FSMONITOR_VALID)) {
45 if (S_ISGITLINK(ce->ce_mode))
46 return;
47 istate->cache_changed |= FSMONITOR_CHANGED;
48 ce->ce_flags |= CE_FSMONITOR_VALID;
49 trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name);
54 * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate
55 * any corresponding untracked cache directory structures. This should
56 * be called any time git creates or modifies a file that should
57 * trigger an lstat() or invalidate the untracked cache for the
58 * corresponding directory
60 static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce)
62 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
64 if (fsm_mode > FSMONITOR_MODE_DISABLED) {
65 ce->ce_flags &= ~CE_FSMONITOR_VALID;
66 untracked_cache_invalidate_path(istate, ce->name, 1);
67 trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name);
71 #endif