MCPcopy Index your code
hub / github.com/git/git / traverse_tree_submodules

Function traverse_tree_submodules

submodule-config.c:885–927  ·  view source on GitHub ↗

* 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'. */

Source from the content-addressed store, hash-verified

883 * with 'root_tree' and 'prefix'.
884 */
885static 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
929void submodules_of_tree(struct repository *r,
930 const struct object_id *treeish_name,

Callers 1

submodules_of_treeFunction · 0.85

Calls 8

fill_tree_descriptorFunction · 0.85
mkpathdupFunction · 0.85
xstrdupFunction · 0.85
is_tree_submodule_activeFunction · 0.85
submodule_from_pathFunction · 0.85
repo_submodule_initFunction · 0.85
tree_entryFunction · 0.70
xmallocFunction · 0.70

Tested by

no test coverage detected