3 #include "cache-tree.h"
6 static void dump_one(struct cache_tree
*it
, const char *pfx
, const char *x
)
8 if (it
->entry_count
< 0)
9 printf("%-40s %s%s (%d subtrees)\n",
10 "invalid", x
, pfx
, it
->subtree_nr
);
12 printf("%s %s%s (%d entries, %d subtrees)\n",
13 sha1_to_hex(it
->sha1
), x
, pfx
,
14 it
->entry_count
, it
->subtree_nr
);
17 static int dump_cache_tree(struct cache_tree
*it
,
18 struct cache_tree
*ref
,
25 /* missing in either */
28 if (it
->entry_count
< 0) {
30 dump_one(it
, pfx
, "");
31 dump_one(ref
, pfx
, "#(ref) ");
34 dump_one(it
, pfx
, "");
35 if (hashcmp(it
->sha1
, ref
->sha1
) ||
36 ref
->entry_count
!= it
->entry_count
||
37 ref
->subtree_nr
!= it
->subtree_nr
) {
38 /* claims to be valid but is lying */
39 dump_one(ref
, pfx
, "#(ref) ");
44 for (i
= 0; i
< it
->subtree_nr
; i
++) {
46 struct cache_tree_sub
*down
= it
->down
[i
];
47 struct cache_tree_sub
*rdwn
;
49 rdwn
= cache_tree_sub(ref
, down
->name
);
50 sprintf(path
, "%s%.*s/", pfx
, down
->namelen
, down
->name
);
51 if (dump_cache_tree(down
->cache_tree
, rdwn
->cache_tree
, path
))
57 int main(int ac
, char **av
)
59 struct index_state istate
;
60 struct cache_tree
*another
= cache_tree();
62 die("unable to read index file");
64 istate
.cache_tree
= another
;
65 cache_tree_update(&istate
, WRITE_TREE_DRY_RUN
);
66 return dump_cache_tree(active_cache_tree
, another
, "");