]> git.ipfire.org Git - thirdparty/git.git/blame - fsmonitor.h
cache.h: remove this no-longer-used header
[thirdparty/git.git] / fsmonitor.h
CommitLineData
883e248b
BP
1#ifndef FSMONITOR_H
2#define FSMONITOR_H
3
ef3ca954 4#include "dir.h"
1e0ea5c4 5#include "fsmonitor-settings.h"
08c46a49
EN
6#include "object.h"
7#include "read-cache-ll.h"
74ea5c95 8#include "trace.h"
ef3ca954 9
883e248b
BP
10extern struct trace_key trace_fsmonitor;
11
12/*
13 * Read the fsmonitor index extension and (if configured) restore the
14 * CE_FSMONITOR_VALID state.
15 */
55454427 16int read_fsmonitor_extension(struct index_state *istate, const void *data, unsigned long sz);
883e248b
BP
17
18/*
3bd28eb2
AV
19 * Fill the fsmonitor_dirty ewah bits with their state from the index,
20 * before it is split during writing.
21 */
55454427 22void fill_fsmonitor_bitmap(struct index_state *istate);
3bd28eb2
AV
23
24/*
25 * Write the CE_FSMONITOR_VALID state into the fsmonitor index
26 * extension. Reads from the fsmonitor_dirty ewah in the index.
883e248b 27 */
55454427 28void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate);
883e248b
BP
29
30/*
31 * Add/remove the fsmonitor index extension
32 */
55454427
DL
33void add_fsmonitor(struct index_state *istate);
34void remove_fsmonitor(struct index_state *istate);
883e248b
BP
35
36/*
37 * Add/remove the fsmonitor index extension as necessary based on the current
38 * core.fsmonitor setting.
39 */
55454427 40void tweak_fsmonitor(struct index_state *istate);
883e248b
BP
41
42/*
43 * Run the configured fsmonitor integration script and clear the
44 * CE_FSMONITOR_VALID bit for any files returned as dirty. Also invalidate
45 * any corresponding untracked cache directory structures. Optimized to only
46 * run the first time it is called.
47 */
55454427 48void refresh_fsmonitor(struct index_state *istate);
883e248b 49
940b94f3
JH
50/*
51 * Does the received result contain the "trivial" response?
52 */
53int fsmonitor_is_trivial_response(const struct strbuf *query_result);
54
0ec9949f
NK
55/*
56 * Check if refresh_fsmonitor has been called at least once.
57 * refresh_fsmonitor is idempotent. Returns true if fsmonitor is
58 * not enabled (since the state will be "fresh" w/ CE_FSMONITOR_VALID unset)
59 * This version is useful for assertions
60 */
61static inline int is_fsmonitor_refreshed(const struct index_state *istate)
62{
1e0ea5c4
JH
63 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
64
65 return fsm_mode <= FSMONITOR_MODE_DISABLED ||
66 istate->fsmonitor_has_run_once;
0ec9949f
NK
67}
68
883e248b
BP
69/*
70 * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
71 * called any time the cache entry has been updated to reflect the
72 * current state of the file on disk.
f954c7b8
JH
73 *
74 * However, never mark submodules as valid. When commands like "git
75 * status" run they might need to recurse into the submodule (using a
76 * child process) to get a summary of the submodule state. We don't
77 * have (and don't want to create) the facility to translate every
78 * FS event that we receive and that happens to be deep inside of a
79 * submodule back to the submodule root, so we cannot correctly keep
80 * track of this bit on the gitlink directory. Therefore, we never
81 * set it on submodules.
883e248b 82 */
b5a81697 83static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache_entry *ce)
883e248b 84{
1e0ea5c4
JH
85 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
86
87 if (fsm_mode > FSMONITOR_MODE_DISABLED &&
88 !(ce->ce_flags & CE_FSMONITOR_VALID)) {
f954c7b8
JH
89 if (S_ISGITLINK(ce->ce_mode))
90 return;
be6b65b9 91 istate->cache_changed |= FSMONITOR_CHANGED;
883e248b
BP
92 ce->ce_flags |= CE_FSMONITOR_VALID;
93 trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name);
94 }
95}
96
97/*
98 * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate
99 * any corresponding untracked cache directory structures. This should
100 * be called any time git creates or modifies a file that should
101 * trigger an lstat() or invalidate the untracked cache for the
102 * corresponding directory
103 */
104static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce)
105{
1e0ea5c4
JH
106 enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
107
108 if (fsm_mode > FSMONITOR_MODE_DISABLED) {
883e248b 109 ce->ce_flags &= ~CE_FSMONITOR_VALID;
0cacebf0 110 untracked_cache_invalidate_path(istate, ce->name, 1);
883e248b
BP
111 trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name);
112 }
113}
114
115#endif