4 #include "cache-tree.h"
7 static void dump_one(struct cache_tree
*it
, const char *pfx
, const char *x
)
9 if (it
->entry_count
< 0)
10 printf("%-40s %s%s (%d subtrees)\n",
11 "invalid", x
, pfx
, it
->subtree_nr
);
13 printf("%s %s%s (%d entries, %d subtrees)\n",
14 oid_to_hex(&it
->oid
), x
, pfx
,
15 it
->entry_count
, it
->subtree_nr
);
18 static int dump_cache_tree(struct cache_tree
*it
,
19 struct cache_tree
*ref
,
26 /* missing in either */
29 if (it
->entry_count
< 0) {
31 dump_one(it
, pfx
, "");
32 dump_one(ref
, pfx
, "#(ref) ");
35 dump_one(it
, pfx
, "");
36 if (!oideq(&it
->oid
, &ref
->oid
) ||
37 ref
->entry_count
!= it
->entry_count
||
38 ref
->subtree_nr
!= it
->subtree_nr
) {
39 /* claims to be valid but is lying */
40 dump_one(ref
, pfx
, "#(ref) ");
45 for (i
= 0; i
< it
->subtree_nr
; i
++) {
47 struct cache_tree_sub
*down
= it
->down
[i
];
48 struct cache_tree_sub
*rdwn
;
50 rdwn
= cache_tree_sub(ref
, down
->name
);
51 xsnprintf(path
, sizeof(path
), "%s%.*s/", pfx
, down
->namelen
, down
->name
);
52 if (dump_cache_tree(down
->cache_tree
, rdwn
->cache_tree
, path
))
58 int cmd__dump_cache_tree(int ac
, const char **av
)
60 struct index_state istate
;
61 struct cache_tree
*another
= cache_tree();
62 setup_git_directory();
64 die("unable to read index file");
66 istate
.cache_tree
= another
;
67 cache_tree_update(&istate
, WRITE_TREE_DRY_RUN
);
68 return dump_cache_tree(active_cache_tree
, another
, "");