Merge branch 'sg/subtree-signed-commits' into pu
[git] / t / helper / test-dump-fsmonitor.c
1 #include "cache.h"
2 #include "config.h"
3
4 int cmd_main(int ac, const char **av)
5 {
6         struct index_state *istate = &the_index;
7         uint64_t now = getnanotime();
8         int i, valid = 0;
9
10         git_config_push_parameter("core.fsmonitor=keep");
11         setup_git_directory();
12         if (read_index_from(istate, get_index_file(), get_git_dir()) < 0)
13                 die("unable to read index file");
14         if (!istate->fsmonitor_last_update) {
15                 printf("no fsmonitor\n");
16                 return 0;
17         }
18
19         printf("fsmonitor last update %"PRIuMAX", (%.2f seconds ago)\n",
20                (uintmax_t)istate->fsmonitor_last_update,
21                (now - istate->fsmonitor_last_update)/1.0e9);
22
23         for (i = 0; i < istate->cache_nr; i++)
24                 if (istate->cache[i]->ce_flags & CE_FSMONITOR_VALID)
25                         valid++;
26
27         printf("  valid: %d\n", valid);
28         printf("  invalid: %d\n", istate->cache_nr - valid);
29
30         return 0;
31 }