Git 2.46-rc0
[git/gitster.git] / t / helper / test-dump-split-index.c
bloba6720faf9ca99d4e523cb2ce056b74867bd4a024
1 #define USE_THE_REPOSITORY_VARIABLE
3 #include "test-tool.h"
4 #include "hex.h"
5 #include "read-cache-ll.h"
6 #include "repository.h"
7 #include "setup.h"
8 #include "split-index.h"
9 #include "ewah/ewok.h"
11 static void show_bit(size_t pos, void *data UNUSED)
13 printf(" %d", (int)pos);
16 int cmd__dump_split_index(int ac UNUSED, const char **av)
18 struct split_index *si;
19 int i;
21 setup_git_directory();
23 do_read_index(the_repository->index, av[1], 1);
24 printf("own %s\n", oid_to_hex(&the_repository->index->oid));
25 si = the_repository->index->split_index;
26 if (!si) {
27 printf("not a split index\n");
28 return 0;
30 printf("base %s\n", oid_to_hex(&si->base_oid));
31 for (i = 0; i < the_repository->index->cache_nr; i++) {
32 struct cache_entry *ce = the_repository->index->cache[i];
33 printf("%06o %s %d\t%s\n", ce->ce_mode,
34 oid_to_hex(&ce->oid), ce_stage(ce), ce->name);
36 printf("replacements:");
37 if (si->replace_bitmap)
38 ewah_each_bit(si->replace_bitmap, show_bit, NULL);
39 printf("\ndeletions:");
40 if (si->delete_bitmap)
41 ewah_each_bit(si->delete_bitmap, show_bit, NULL);
42 printf("\n");
43 return 0;