index: make the index file format extensible.
[git/debian.git] / dump-cache-tree.c
blob01e8bff0ee0e750b433375b7d7eb72c641f23204
1 #include "cache.h"
2 #include "tree.h"
3 #include "cache-tree.h"
5 static void dump_cache_tree(struct cache_tree *it, const char *pfx)
7 int i;
8 if (!it)
9 return;
10 if (it->entry_count < 0)
11 printf("%-40s %s\n", "invalid", pfx);
12 else
13 printf("%s %s (%d entries)\n",
14 sha1_to_hex(it->sha1),
15 pfx, it->entry_count);
16 for (i = 0; i < it->subtree_nr; i++) {
17 char path[PATH_MAX];
18 struct cache_tree_sub *down = it->down[i];
19 sprintf(path, "%s%.*s/", pfx, down->namelen, down->name);
20 dump_cache_tree(down->cache_tree, path);
24 int main(int ac, char **av)
26 if (read_cache() < 0)
27 die("unable to read index file");
28 dump_cache_tree(active_cache_tree, "");
29 return 0;