@matheusbsbs / matheus-bagliano / commits / 53dc3f3e80
Fork 0

Teach fsck-objects about cache-tree.

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Apr 25, 2006 at 16:37 UTC 53dc3f3e8069283924fcb7f1d538e2d1b03ec3bb
1 file changed +18
fsck-objects.c
+18
@@ -8,6 +8,7 @@
8 #include "tag.h"
9 #include "refs.h"
10 #include "pack.h"
11 +#include "cache-tree.h"
12
13 #define REACHABLE 0x0001
14
@@ -438,6 +439,21 @@ static int fsck_head_link(void)
439 return 0;
440 }
441
442 +static int fsck_cache_tree(struct cache_tree *it)
443 +{
444 + int i;
445 + int err = 0;
446 +
447 + if (0 <= it->entry_count) {
448 + struct object *obj = parse_object(it->sha1);
449 + if (obj->type != tree_type)
450 + err |= objerror(obj, "non-tree in cache-tree");
451 + }
452 + for (i = 0; i < it->subtree_nr; i++)
453 + err |= fsck_cache_tree(it->down[i]->cache_tree);
454 + return err;
455 +}
456 +
457 int main(int argc, char **argv)
458 {
459 int i, heads;
@@ -547,6 +563,8 @@ int main(int argc, char **argv)
563 obj->used = 1;
564 mark_reachable(obj, REACHABLE);
565 }
566 + if (active_cache_tree)
567 + fsck_cache_tree(active_cache_tree);
568 }
569
570 check_connectivity();