Merge branch 'bw/mingw-avoid-inheriting-fd-to-lockfile' into maint
[git] / t / helper / test-dump-split-index.c
1 #include "cache.h"
2 #include "split-index.h"
3 #include "ewah/ewok.h"
4
5 static void show_bit(size_t pos, void *data)
6 {
7         printf(" %d", (int)pos);
8 }
9
10 int cmd_main(int ac, const char **av)
11 {
12         struct split_index *si;
13         int i;
14
15         do_read_index(&the_index, av[1], 1);
16         printf("own %s\n", sha1_to_hex(the_index.sha1));
17         si = the_index.split_index;
18         if (!si) {
19                 printf("not a split index\n");
20                 return 0;
21         }
22         printf("base %s\n", sha1_to_hex(si->base_sha1));
23         for (i = 0; i < the_index.cache_nr; i++) {
24                 struct cache_entry *ce = the_index.cache[i];
25                 printf("%06o %s %d\t%s\n", ce->ce_mode,
26                        sha1_to_hex(ce->sha1), ce_stage(ce), ce->name);
27         }
28         printf("replacements:");
29         if (si->replace_bitmap)
30                 ewah_each_bit(si->replace_bitmap, show_bit, NULL);
31         printf("\ndeletions:");
32         if (si->delete_bitmap)
33                 ewah_each_bit(si->delete_bitmap, show_bit, NULL);
34         printf("\n");
35         return 0;
36 }