| 12 | const char *tree_type = "tree"; |
| 13 | |
| 14 | int read_tree_at(struct repository *r, |
| 15 | struct tree *tree, struct strbuf *base, |
| 16 | int depth, |
| 17 | const struct pathspec *pathspec, |
| 18 | read_tree_fn_t fn, void *context) |
| 19 | { |
| 20 | struct tree_desc desc; |
| 21 | struct name_entry entry; |
| 22 | struct object_id oid; |
| 23 | int len, oldlen = base->len; |
| 24 | enum interesting retval = entry_not_interesting; |
| 25 | |
| 26 | if (depth > r->settings.max_allowed_tree_depth) |
| 27 | return error("exceeded maximum allowed tree depth"); |
| 28 | |
| 29 | if (repo_parse_tree(r, tree)) |
| 30 | return -1; |
| 31 | |
| 32 | init_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size); |
| 33 | |
| 34 | while (tree_entry(&desc, &entry)) { |
| 35 | if (retval != all_entries_interesting) { |
| 36 | retval = tree_entry_interesting(r->index, &entry, |
| 37 | base, pathspec); |
| 38 | if (retval == all_entries_not_interesting) |
| 39 | break; |
| 40 | if (retval == entry_not_interesting) |
| 41 | continue; |
| 42 | } |
| 43 | |
| 44 | switch (fn(&entry.oid, base, |
| 45 | entry.path, entry.mode, context)) { |
| 46 | case 0: |
| 47 | continue; |
| 48 | case READ_TREE_RECURSIVE: |
| 49 | break; |
| 50 | default: |
| 51 | return -1; |
| 52 | } |
| 53 | |
| 54 | if (S_ISDIR(entry.mode)) |
| 55 | oidcpy(&oid, &entry.oid); |
| 56 | else if (S_ISGITLINK(entry.mode)) { |
| 57 | struct commit *commit; |
| 58 | |
| 59 | commit = lookup_commit(r, &entry.oid); |
| 60 | if (!commit) |
| 61 | die("Commit %s in submodule path %s%s not found", |
| 62 | oid_to_hex(&entry.oid), |
| 63 | base->buf, entry.path); |
| 64 | |
| 65 | if (repo_parse_commit(r, commit)) |
| 66 | die("Invalid commit %s in submodule path %s%s", |
| 67 | oid_to_hex(&entry.oid), |
| 68 | base->buf, entry.path); |
| 69 | |
| 70 | oidcpy(&oid, get_commit_tree_oid(commit)); |
| 71 | } |
no test coverage detected