fsmonitor: read from getcwd(), not the PWD environment variable
[git/git.git] / fsmonitor.h
CommitLineData
883e248b
BP
1#ifndef FSMONITOR_H
2#define FSMONITOR_H
3
4extern struct trace_key trace_fsmonitor;
5
6/*
7 * Read the fsmonitor index extension and (if configured) restore the
8 * CE_FSMONITOR_VALID state.
9 */
10extern int read_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 */
15extern void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate);
16
17/*
18 * Add/remove the fsmonitor index extension
19 */
20extern void add_fsmonitor(struct index_state *istate);
21extern void remove_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 */
27extern void tweak_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 */
35extern void refresh_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 */
42static inline void mark_fsmonitor_valid(struct cache_entry *ce)
43{
44 if (core_fsmonitor) {
45 ce->ce_flags |= CE_FSMONITOR_VALID;
46 trace_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 */
57static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce)
58{
59 if (core_fsmonitor) {
60 ce->ce_flags &= ~CE_FSMONITOR_VALID;
61 untracked_cache_invalidate_path(istate, ce->name);
62 trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name);
63 }
64}
65
66#endif