| 97 | } |
| 98 | |
| 99 | static bool tpt_counts(tpt_context *c, const cbm_git_tree_inventory_t *inventory, |
| 100 | size_t *directories) { |
| 101 | const cbm_git_tree_entry_t *previous = NULL; |
| 102 | *directories = 1; |
| 103 | for (size_t i = 0; i < inventory->count; i++) { |
| 104 | if (!tpt_poll(c) || !tpt_inventory_row(c, &inventory->entries[i], previous)) |
| 105 | return false; |
| 106 | previous = &inventory->entries[i]; |
| 107 | } |
| 108 | previous = NULL; |
| 109 | for (size_t i = 0; i < inventory->count; i++) { |
| 110 | const cbm_git_tree_entry_t *entry = &inventory->entries[i]; |
| 111 | if (!tpt_poll(c)) |
| 112 | return false; |
| 113 | for (size_t j = 0; j < entry->path_length; j++) { |
| 114 | if (entry->path[j] != '/' || !tpt_prefix_new(c, entry, previous, j)) |
| 115 | continue; |
| 116 | if (!tpt_file_prefix(c, inventory, entry->path, j)) |
| 117 | return false; |
| 118 | if (*directories >= c->tree->limits.max_directories) |
| 119 | return tpt_fail(c, CBM_PINNED_TREE_LIMIT, "directory count limit"); |
| 120 | (*directories)++; |
| 121 | } |
| 122 | previous = entry; |
| 123 | } |
| 124 | return tpt_poll(c); |
| 125 | } |
| 126 | |
| 127 | static size_t tpt_find_directory(tpt_context *c, const char *path, size_t n, size_t used) { |
| 128 | if (!n) |
no test coverage detected