]>
Commit | Line | Data |
---|---|---|
883e248b BP |
1 | #ifndef FSMONITOR_H |
2 | #define FSMONITOR_H | |
3 | ||
ef3ca954 EN |
4 | #include "cache.h" |
5 | #include "dir.h" | |
6 | ||
883e248b BP |
7 | extern struct trace_key trace_fsmonitor; |
8 | ||
9 | /* | |
10 | * Read the fsmonitor index extension and (if configured) restore the | |
11 | * CE_FSMONITOR_VALID state. | |
12 | */ | |
55454427 | 13 | int read_fsmonitor_extension(struct index_state *istate, const void *data, unsigned long sz); |
883e248b BP |
14 | |
15 | /* | |
3bd28eb2 AV |
16 | * Fill the fsmonitor_dirty ewah bits with their state from the index, |
17 | * before it is split during writing. | |
18 | */ | |
55454427 | 19 | void fill_fsmonitor_bitmap(struct index_state *istate); |
3bd28eb2 AV |
20 | |
21 | /* | |
22 | * Write the CE_FSMONITOR_VALID state into the fsmonitor index | |
23 | * extension. Reads from the fsmonitor_dirty ewah in the index. | |
883e248b | 24 | */ |
55454427 | 25 | void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate); |
883e248b BP |
26 | |
27 | /* | |
28 | * Add/remove the fsmonitor index extension | |
29 | */ | |
55454427 DL |
30 | void add_fsmonitor(struct index_state *istate); |
31 | void remove_fsmonitor(struct index_state *istate); | |
883e248b BP |
32 | |
33 | /* | |
34 | * Add/remove the fsmonitor index extension as necessary based on the current | |
35 | * core.fsmonitor setting. | |
36 | */ | |
55454427 | 37 | void tweak_fsmonitor(struct index_state *istate); |
883e248b BP |
38 | |
39 | /* | |
40 | * Run the configured fsmonitor integration script and clear the | |
41 | * CE_FSMONITOR_VALID bit for any files returned as dirty. Also invalidate | |
42 | * any corresponding untracked cache directory structures. Optimized to only | |
43 | * run the first time it is called. | |
44 | */ | |
55454427 | 45 | void refresh_fsmonitor(struct index_state *istate); |
883e248b | 46 | |
940b94f3 JH |
47 | /* |
48 | * Does the received result contain the "trivial" response? | |
49 | */ | |
50 | int fsmonitor_is_trivial_response(const struct strbuf *query_result); | |
51 | ||
0ec9949f NK |
52 | /* |
53 | * Check if refresh_fsmonitor has been called at least once. | |
54 | * refresh_fsmonitor is idempotent. Returns true if fsmonitor is | |
55 | * not enabled (since the state will be "fresh" w/ CE_FSMONITOR_VALID unset) | |
56 | * This version is useful for assertions | |
57 | */ | |
58 | static inline int is_fsmonitor_refreshed(const struct index_state *istate) | |
59 | { | |
60 | return !core_fsmonitor || istate->fsmonitor_has_run_once; | |
61 | } | |
62 | ||
883e248b BP |
63 | /* |
64 | * Set the given cache entries CE_FSMONITOR_VALID bit. This should be | |
65 | * called any time the cache entry has been updated to reflect the | |
66 | * current state of the file on disk. | |
67 | */ | |
b5a81697 | 68 | static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache_entry *ce) |
883e248b | 69 | { |
b5a81697 JS |
70 | if (core_fsmonitor && !(ce->ce_flags & CE_FSMONITOR_VALID)) { |
71 | istate->cache_changed = 1; | |
883e248b BP |
72 | ce->ce_flags |= CE_FSMONITOR_VALID; |
73 | trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name); | |
74 | } | |
75 | } | |
76 | ||
77 | /* | |
78 | * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate | |
79 | * any corresponding untracked cache directory structures. This should | |
80 | * be called any time git creates or modifies a file that should | |
81 | * trigger an lstat() or invalidate the untracked cache for the | |
82 | * corresponding directory | |
83 | */ | |
84 | static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce) | |
85 | { | |
86 | if (core_fsmonitor) { | |
87 | ce->ce_flags &= ~CE_FSMONITOR_VALID; | |
0cacebf0 | 88 | untracked_cache_invalidate_path(istate, ce->name, 1); |
883e248b BP |
89 | trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name); |
90 | } | |
91 | } | |
92 | ||
93 | #endif |