Skip to content

Commit dd3551f

Browse files
benpeartgitster
authored andcommitted
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>
1 parent 9d406cb commit dd3551f

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ TEST_PROGRAMS_NEED_X += test-config
639639
TEST_PROGRAMS_NEED_X += test-date
640640
TEST_PROGRAMS_NEED_X += test-delta
641641
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
642+
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
642643
TEST_PROGRAMS_NEED_X += test-dump-split-index
643644
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
644645
TEST_PROGRAMS_NEED_X += test-fake-ssh

t/helper/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/test-date
55
/test-delta
66
/test-dump-cache-tree
7+
/test-dump-fsmonitor
78
/test-dump-split-index
89
/test-dump-untracked-cache
910
/test-fake-ssh

t/helper/test-dump-fsmonitor.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)