1#ifndef FSMONITOR_H 2#define FSMONITOR_H 3 4externstruct trace_key trace_fsmonitor; 5 6/* 7 * Read the fsmonitor index extension and (if configured) restore the 8 * CE_FSMONITOR_VALID state. 9 */ 10externintread_fsmonitor_extension(struct index_state *istate,const void*data,unsigned long sz); 11 12/* 13 * Write the CE_FSMONITOR_VALID state into the fsmonitor index extension. 14 */ 15externvoidwrite_fsmonitor_extension(struct strbuf *sb,struct index_state *istate); 16 17/* 18 * Add/remove the fsmonitor index extension 19 */ 20externvoidadd_fsmonitor(struct index_state *istate); 21externvoidremove_fsmonitor(struct index_state *istate); 22 23/* 24 * Add/remove the fsmonitor index extension as necessary based on the current 25 * core.fsmonitor setting. 26 */ 27externvoidtweak_fsmonitor(struct index_state *istate); 28 29/* 30 * Run the configured fsmonitor integration script and clear the 31 * CE_FSMONITOR_VALID bit for any files returned as dirty. Also invalidate 32 * any corresponding untracked cache directory structures. Optimized to only 33 * run the first time it is called. 34 */ 35externvoidrefresh_fsmonitor(struct index_state *istate); 36 37/* 38 * Set the given cache entries CE_FSMONITOR_VALID bit. This should be 39 * called any time the cache entry has been updated to reflect the 40 * current state of the file on disk. 41 */ 42staticinlinevoidmark_fsmonitor_valid(struct cache_entry *ce) 43{ 44if(core_fsmonitor) { 45 ce->ce_flags |= CE_FSMONITOR_VALID; 46trace_printf_key(&trace_fsmonitor,"mark_fsmonitor_clean '%s'", ce->name); 47} 48} 49 50/* 51 * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate 52 * any corresponding untracked cache directory structures. This should 53 * be called any time git creates or modifies a file that should 54 * trigger an lstat() or invalidate the untracked cache for the 55 * corresponding directory 56 */ 57staticinlinevoidmark_fsmonitor_invalid(struct index_state *istate,struct cache_entry *ce) 58{ 59if(core_fsmonitor) { 60 ce->ce_flags &= ~CE_FSMONITOR_VALID; 61untracked_cache_invalidate_path(istate, ce->name); 62trace_printf_key(&trace_fsmonitor,"mark_fsmonitor_invalid '%s'", ce->name); 63} 64} 65 66#endif