summaryrefslogtreecommitdiff
path: root/submodule-config.c
diff options
context:
space:
mode:
Diffstat (limited to 'submodule-config.c')
-rw-r--r--submodule-config.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/submodule-config.c b/submodule-config.c
index 9b0bb0b9f4..9c8c37b259 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -95,7 +95,7 @@ static void free_one_config(struct submodule_entry *entry)
free((void *) entry->config->branch);
free((void *) entry->config->url);
free((void *) entry->config->ignore);
- free((void *) entry->config->update_strategy.command);
+ submodule_update_strategy_release(&entry->config->update_strategy);
free(entry->config);
}
@@ -899,27 +899,26 @@ static void traverse_tree_submodules(struct repository *r,
{
struct tree_desc tree;
struct submodule_tree_entry *st_entry;
- struct name_entry *name_entry;
+ struct name_entry name_entry;
char *tree_path = NULL;
+ char *tree_buf;
- name_entry = xmalloc(sizeof(*name_entry));
-
- fill_tree_descriptor(r, &tree, treeish_name);
- while (tree_entry(&tree, name_entry)) {
+ tree_buf = fill_tree_descriptor(r, &tree, treeish_name);
+ while (tree_entry(&tree, &name_entry)) {
if (prefix)
tree_path =
- mkpathdup("%s/%s", prefix, name_entry->path);
+ mkpathdup("%s/%s", prefix, name_entry.path);
else
- tree_path = xstrdup(name_entry->path);
+ tree_path = xstrdup(name_entry.path);
- if (S_ISGITLINK(name_entry->mode) &&
+ if (S_ISGITLINK(name_entry.mode) &&
is_tree_submodule_active(r, root_tree, tree_path)) {
ALLOC_GROW(out->entries, out->entry_nr + 1,
out->entry_alloc);
st_entry = &out->entries[out->entry_nr++];
st_entry->name_entry = xmalloc(sizeof(*st_entry->name_entry));
- *st_entry->name_entry = *name_entry;
+ *st_entry->name_entry = name_entry;
st_entry->submodule =
submodule_from_path(r, root_tree, tree_path);
st_entry->repo = xmalloc(sizeof(*st_entry->repo));
@@ -927,11 +926,13 @@ static void traverse_tree_submodules(struct repository *r,
root_tree))
FREE_AND_NULL(st_entry->repo);
- } else if (S_ISDIR(name_entry->mode))
+ } else if (S_ISDIR(name_entry.mode))
traverse_tree_submodules(r, root_tree, tree_path,
- &name_entry->oid, out);
+ &name_entry.oid, out);
free(tree_path);
}
+
+ free(tree_buf);
}
void submodules_of_tree(struct repository *r,
@@ -945,6 +946,16 @@ void submodules_of_tree(struct repository *r,
traverse_tree_submodules(r, treeish_name, NULL, treeish_name, out);
}
+void submodule_entry_list_release(struct submodule_entry_list *list)
+{
+ for (size_t i = 0; i < list->entry_nr; i++) {
+ free(list->entries[i].name_entry);
+ repo_clear(list->entries[i].repo);
+ free(list->entries[i].repo);
+ }
+ free(list->entries);
+}
+
void submodule_free(struct repository *r)
{
if (r->submodule_cache)