fsmonitor: add a test tool to dump the index extension
Add a test utility (test-dump-fsmonitor) that will dump the fsmonitor index extension. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ben Peart committed
Sep 22, 2017 at 12:35 UTC
dd3551f4918967f7153150fd615054d7878490e4
3 files changed
+23
Makefile
+1
@@ -639,6 +639,7 @@ TEST_PROGRAMS_NEED_X += test-config
639
TEST_PROGRAMS_NEED_X += test-date
640
TEST_PROGRAMS_NEED_X += test-delta
641
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
642
+TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
643
TEST_PROGRAMS_NEED_X += test-dump-split-index
644
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
645
TEST_PROGRAMS_NEED_X += test-fake-ssh
t/helper/.gitignore
+1
@@ -4,6 +4,7 @@
4
/test-date
5
/test-delta
6
/test-dump-cache-tree
7
+/test-dump-fsmonitor
8
/test-dump-split-index
9
/test-dump-untracked-cache
10
/test-fake-ssh
t/helper/test-dump-fsmonitor.c
new
+21
@@ -0,0 +1,21 @@
1
+#include "cache.h"
2
+
3
+int cmd_main(int ac, const char **av)
4
+{
5
+ struct index_state *istate = &the_index;
6
+ int i;
7
+
8
+ setup_git_directory();
9
+ if (do_read_index(istate, get_index_file(), 0) < 0)
10
+ die("unable to read index file");
11
+ if (!istate->fsmonitor_last_update) {
12
+ printf("no fsmonitor\n");
13
+ return 0;
14
+ }
15
+ printf("fsmonitor last update %"PRIuMAX"\n", (uintmax_t)istate->fsmonitor_last_update);
16
+
17
+ for (i = 0; i < istate->cache_nr; i++)
18
+ printf((istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) ? "+" : "-");
19
+
20
+ return 0;
21
+}