* Used internally by submodules_of_tree(). Recurses into 'treeish_name' * and appends submodule entries to 'out'. The submodule_cache expects * a root-level treeish_name and paths, so keep track of these values * with 'root_tree' and 'prefix'. */
| 883 | * with 'root_tree' and 'prefix'. |
| 884 | */ |
| 885 | static void traverse_tree_submodules(struct repository *r, |
| 886 | const struct object_id *root_tree, |
| 887 | char *prefix, |
| 888 | const struct object_id *treeish_name, |
| 889 | struct submodule_entry_list *out) |
| 890 | { |
| 891 | struct tree_desc tree; |
| 892 | struct submodule_tree_entry *st_entry; |
| 893 | struct name_entry name_entry; |
| 894 | char *tree_path = NULL; |
| 895 | char *tree_buf; |
| 896 | |
| 897 | tree_buf = fill_tree_descriptor(r, &tree, treeish_name); |
| 898 | while (tree_entry(&tree, &name_entry)) { |
| 899 | if (prefix) |
| 900 | tree_path = |
| 901 | mkpathdup("%s/%s", prefix, name_entry.path); |
| 902 | else |
| 903 | tree_path = xstrdup(name_entry.path); |
| 904 | |
| 905 | if (S_ISGITLINK(name_entry.mode) && |
| 906 | is_tree_submodule_active(r, root_tree, tree_path)) { |
| 907 | ALLOC_GROW(out->entries, out->entry_nr + 1, |
| 908 | out->entry_alloc); |
| 909 | st_entry = &out->entries[out->entry_nr++]; |
| 910 | |
| 911 | st_entry->name_entry = xmalloc(sizeof(*st_entry->name_entry)); |
| 912 | *st_entry->name_entry = name_entry; |
| 913 | st_entry->submodule = |
| 914 | submodule_from_path(r, root_tree, tree_path); |
| 915 | st_entry->repo = xmalloc(sizeof(*st_entry->repo)); |
| 916 | if (repo_submodule_init(st_entry->repo, r, tree_path, |
| 917 | root_tree)) |
| 918 | FREE_AND_NULL(st_entry->repo); |
| 919 | |
| 920 | } else if (S_ISDIR(name_entry.mode)) |
| 921 | traverse_tree_submodules(r, root_tree, tree_path, |
| 922 | &name_entry.oid, out); |
| 923 | free(tree_path); |
| 924 | } |
| 925 | |
| 926 | free(tree_buf); |
| 927 | } |
| 928 | |
| 929 | void submodules_of_tree(struct repository *r, |
| 930 | const struct object_id *treeish_name, |
no test coverage detected