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