Coverage Report

Created: 2024-09-08 06:23

/src/git/fsmonitor.h
Line
Count
Source (jump to first uncovered line)
1
#ifndef FSMONITOR_H
2
#define FSMONITOR_H
3
4
#include "fsmonitor-ll.h"
5
#include "dir.h"
6
#include "fsmonitor-settings.h"
7
#include "object.h"
8
#include "read-cache-ll.h"
9
#include "trace.h"
10
11
/*
12
 * Check if refresh_fsmonitor has been called at least once.
13
 * refresh_fsmonitor is idempotent. Returns true if fsmonitor is
14
 * not enabled (since the state will be "fresh" w/ CE_FSMONITOR_VALID unset)
15
 * This version is useful for assertions
16
 */
17
static inline int is_fsmonitor_refreshed(const struct index_state *istate)
18
0
{
19
0
  enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
20
0
21
0
  return fsm_mode <= FSMONITOR_MODE_DISABLED ||
22
0
    istate->fsmonitor_has_run_once;
23
0
}
Unexecuted instantiation: update-index.c:is_fsmonitor_refreshed
Unexecuted instantiation: diff-lib.c:is_fsmonitor_refreshed
Unexecuted instantiation: entry.c:is_fsmonitor_refreshed
Unexecuted instantiation: fsmonitor.c:is_fsmonitor_refreshed
Unexecuted instantiation: preload-index.c:is_fsmonitor_refreshed
Unexecuted instantiation: read-cache.c:is_fsmonitor_refreshed
Unexecuted instantiation: unpack-trees.c:is_fsmonitor_refreshed
24
25
/*
26
 * Set the given cache entries CE_FSMONITOR_VALID bit. This should be
27
 * called any time the cache entry has been updated to reflect the
28
 * current state of the file on disk.
29
 *
30
 * However, never mark submodules as valid.  When commands like "git
31
 * status" run they might need to recurse into the submodule (using a
32
 * child process) to get a summary of the submodule state.  We don't
33
 * have (and don't want to create) the facility to translate every
34
 * FS event that we receive and that happens to be deep inside of a
35
 * submodule back to the submodule root, so we cannot correctly keep
36
 * track of this bit on the gitlink directory.  Therefore, we never
37
 * set it on submodules.
38
 */
39
static inline void mark_fsmonitor_valid(struct index_state *istate, struct cache_entry *ce)
40
0
{
41
0
  enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
42
43
0
  if (fsm_mode > FSMONITOR_MODE_DISABLED &&
44
0
      !(ce->ce_flags & CE_FSMONITOR_VALID)) {
45
0
    if (S_ISGITLINK(ce->ce_mode))
46
0
      return;
47
0
    istate->cache_changed |= FSMONITOR_CHANGED;
48
0
    ce->ce_flags |= CE_FSMONITOR_VALID;
49
0
    trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name);
50
0
  }
51
0
}
Unexecuted instantiation: update-index.c:mark_fsmonitor_valid
Unexecuted instantiation: diff-lib.c:mark_fsmonitor_valid
Unexecuted instantiation: entry.c:mark_fsmonitor_valid
Unexecuted instantiation: fsmonitor.c:mark_fsmonitor_valid
Unexecuted instantiation: preload-index.c:mark_fsmonitor_valid
Unexecuted instantiation: read-cache.c:mark_fsmonitor_valid
Unexecuted instantiation: unpack-trees.c:mark_fsmonitor_valid
52
53
/*
54
 * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate
55
 * any corresponding untracked cache directory structures. This should
56
 * be called any time git creates or modifies a file that should
57
 * trigger an lstat() or invalidate the untracked cache for the
58
 * corresponding directory
59
 */
60
static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce)
61
0
{
62
0
  enum fsmonitor_mode fsm_mode = fsm_settings__get_mode(istate->repo);
63
64
0
  if (fsm_mode > FSMONITOR_MODE_DISABLED) {
65
0
    ce->ce_flags &= ~CE_FSMONITOR_VALID;
66
0
    untracked_cache_invalidate_path(istate, ce->name, 1);
67
0
    trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name);
68
0
  }
69
0
}
Unexecuted instantiation: update-index.c:mark_fsmonitor_invalid
Unexecuted instantiation: diff-lib.c:mark_fsmonitor_invalid
Unexecuted instantiation: entry.c:mark_fsmonitor_invalid
Unexecuted instantiation: fsmonitor.c:mark_fsmonitor_invalid
Unexecuted instantiation: preload-index.c:mark_fsmonitor_invalid
Unexecuted instantiation: read-cache.c:mark_fsmonitor_invalid
Unexecuted instantiation: unpack-trees.c:mark_fsmonitor_invalid
70
71
#endif