Blame fsmonitor.h

Packit 4511e4
#ifndef FSMONITOR_H
Packit 4511e4
#define FSMONITOR_H
Packit 4511e4
Packit Service b5fd21
#include "cache.h"
Packit Service b5fd21
#include "dir.h"
Packit Service b5fd21
Packit 4511e4
extern struct trace_key trace_fsmonitor;
Packit 4511e4
Packit 4511e4
/*
Packit 4511e4
 * Read the fsmonitor index extension and (if configured) restore the
Packit 4511e4
 * CE_FSMONITOR_VALID state.
Packit 4511e4
 */
Packit Service b5fd21
int read_fsmonitor_extension(struct index_state *istate, const void *data, unsigned long sz);
Packit 4511e4
Packit 4511e4
/*
Packit 4511e4
 * Fill the fsmonitor_dirty ewah bits with their state from the index,
Packit 4511e4
 * before it is split during writing.
Packit 4511e4
 */
Packit Service b5fd21
void fill_fsmonitor_bitmap(struct index_state *istate);
Packit 4511e4
Packit 4511e4
/*
Packit 4511e4
 * Write the CE_FSMONITOR_VALID state into the fsmonitor index
Packit 4511e4
 * extension.  Reads from the fsmonitor_dirty ewah in the index.
Packit 4511e4
 */
Packit Service b5fd21
void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate);
Packit 4511e4
Packit 4511e4
/*
Packit 4511e4
 * Add/remove the fsmonitor index extension
Packit 4511e4
 */
Packit Service b5fd21
void add_fsmonitor(struct index_state *istate);
Packit Service b5fd21
void remove_fsmonitor(struct index_state *istate);
Packit 4511e4
Packit 4511e4
/*
Packit 4511e4
 * Add/remove the fsmonitor index extension as necessary based on the current
Packit 4511e4
 * core.fsmonitor setting.
Packit 4511e4
 */
Packit Service b5fd21
void tweak_fsmonitor(struct index_state *istate);
Packit 4511e4
Packit 4511e4
/*
Packit 4511e4
 * Run the configured fsmonitor integration script and clear the
Packit 4511e4
 * CE_FSMONITOR_VALID bit for any files returned as dirty.  Also invalidate
Packit 4511e4
 * any corresponding untracked cache directory structures. Optimized to only
Packit 4511e4
 * run the first time it is called.
Packit 4511e4
 */
Packit Service b5fd21
void refresh_fsmonitor(struct index_state *istate);
Packit 4511e4
Packit 4511e4
/*
Packit 4511e4
 * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
Packit 4511e4
 * called any time the cache entry has been updated to reflect the
Packit 4511e4
 * current state of the file on disk.
Packit 4511e4
 */
Packit Service b5fd21
static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache_entry *ce)
Packit 4511e4
{
Packit Service b5fd21
	if (core_fsmonitor && !(ce->ce_flags & CE_FSMONITOR_VALID)) {
Packit Service b5fd21
		istate->cache_changed = 1;
Packit 4511e4
		ce->ce_flags |= CE_FSMONITOR_VALID;
Packit 4511e4
		trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name);
Packit 4511e4
	}
Packit 4511e4
}
Packit 4511e4
Packit 4511e4
/*
Packit 4511e4
 * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate
Packit 4511e4
 * any corresponding untracked cache directory structures. This should
Packit 4511e4
 * be called any time git creates or modifies a file that should
Packit 4511e4
 * trigger an lstat() or invalidate the untracked cache for the
Packit 4511e4
 * corresponding directory
Packit 4511e4
 */
Packit 4511e4
static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce)
Packit 4511e4
{
Packit 4511e4
	if (core_fsmonitor) {
Packit 4511e4
		ce->ce_flags &= ~CE_FSMONITOR_VALID;
Packit 4511e4
		untracked_cache_invalidate_path(istate, ce->name, 1);
Packit 4511e4
		trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name);
Packit 4511e4
	}
Packit 4511e4
}
Packit 4511e4
Packit 4511e4
#endif