Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/fsmonitor.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / fsmonitor.h` 71 lines ยท 2521 bytes Raw Blame History 1 #ifndef FSMONITOR_H 2 #define FSMONITOR_H 3 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" 10 11 /* 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 16 */ 17 static inline int is_fsmonitor_refreshed(const struct index_state *istate) 18 { 19 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo); 20 21 return fsm_mode <= FSMONITOR_MODE_DISABLED || 22 istate->fsmonitor_has_run_once; 23 } 24 25 /* 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. 29 * 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. 38 */ 39 static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache_entry *ce) 40 { 41 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo); 42 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); 50 } 51 } 52 53 /* 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 59 */ 60 static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce) 61 { 62 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo); 63 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); 68 } 69 } 70 71 #endif