| 614 | } |
| 615 | |
| 616 | static int fsck_tree(const struct object_id *tree_oid, |
| 617 | const char *buffer, unsigned long size, |
| 618 | struct fsck_options *options) |
| 619 | { |
| 620 | int retval = 0; |
| 621 | int has_null_sha1 = 0; |
| 622 | int has_full_path = 0; |
| 623 | int has_empty_name = 0; |
| 624 | int has_dot = 0; |
| 625 | int has_dotdot = 0; |
| 626 | int has_dotgit = 0; |
| 627 | int has_zero_pad = 0; |
| 628 | int has_bad_modes = 0; |
| 629 | int has_dup_entries = 0; |
| 630 | int not_properly_sorted = 0; |
| 631 | int has_large_name = 0; |
| 632 | struct tree_desc desc; |
| 633 | unsigned o_mode; |
| 634 | const char *o_name; |
| 635 | struct name_stack df_dup_candidates = { NULL }; |
| 636 | |
| 637 | if (init_tree_desc_gently(&desc, tree_oid, buffer, size, |
| 638 | TREE_DESC_RAW_MODES)) { |
| 639 | retval += report(options, tree_oid, OBJ_TREE, |
| 640 | FSCK_MSG_BAD_TREE, |
| 641 | "cannot be parsed as a tree"); |
| 642 | return retval; |
| 643 | } |
| 644 | |
| 645 | o_mode = 0; |
| 646 | o_name = NULL; |
| 647 | |
| 648 | while (desc.size) { |
| 649 | unsigned short mode; |
| 650 | const char *name, *backslash; |
| 651 | const struct object_id *entry_oid; |
| 652 | |
| 653 | entry_oid = tree_entry_extract(&desc, &name, &mode); |
| 654 | |
| 655 | has_null_sha1 |= is_null_oid(entry_oid); |
| 656 | has_full_path |= !!strchr(name, '/'); |
| 657 | has_empty_name |= !*name; |
| 658 | has_dot |= !strcmp(name, "."); |
| 659 | has_dotdot |= !strcmp(name, ".."); |
| 660 | has_dotgit |= is_hfs_dotgit(name) || is_ntfs_dotgit(name); |
| 661 | has_zero_pad |= *(char *)desc.buffer == '0'; |
| 662 | has_large_name |= tree_entry_len(&desc.entry) > max_tree_entry_len; |
| 663 | |
| 664 | if (is_hfs_dotgitmodules(name) || is_ntfs_dotgitmodules(name)) { |
| 665 | if (!S_ISLNK(mode)) |
| 666 | oidset_insert(&options->gitmodules_found, |
| 667 | entry_oid); |
| 668 | else |
| 669 | retval += report(options, |
| 670 | tree_oid, OBJ_TREE, |
| 671 | FSCK_MSG_GITMODULES_SYMLINK, |
| 672 | ".gitmodules is a symbolic link"); |
| 673 | } |
no test coverage detected