1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-06 21:36:12 +02:00

submodule: store OIDs in changed_submodule_names

'calculate_changed_submodule_paths' uses a local list to compute the
changed submodules, and then produces the result by copying appropriate
items into the result list.

Instead use the result list directly and prune items afterwards
using string_list_remove_empty_items.

By doing so we'll have access to the util pointer for longer that
contains the commits that we need to fetch, which will be
useful in a later patch.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Stefan Beller 2018-11-28 16:27:52 -08:00 committed by Junio C Hamano
parent 16dd6fe133
commit bcd7337243

View File

@ -1139,8 +1139,7 @@ static void calculate_changed_submodule_paths(struct repository *r,
struct string_list *changed_submodule_names)
{
struct argv_array argv = ARGV_ARRAY_INIT;
struct string_list changed_submodules = STRING_LIST_INIT_DUP;
const struct string_list_item *name;
struct string_list_item *name;
/* No need to check if there are no submodules configured */
if (!submodule_from_path(r, NULL, NULL))
@ -1157,9 +1156,9 @@ static void calculate_changed_submodule_paths(struct repository *r,
* Collect all submodules (whether checked out or not) for which new
* commits have been recorded upstream in "changed_submodule_names".
*/
collect_changed_submodules(r, &changed_submodules, &argv);
collect_changed_submodules(r, changed_submodule_names, &argv);
for_each_string_list_item(name, &changed_submodules) {
for_each_string_list_item(name, changed_submodule_names) {
struct oid_array *commits = name->util;
const struct submodule *submodule;
const char *path = NULL;
@ -1173,12 +1172,14 @@ static void calculate_changed_submodule_paths(struct repository *r,
if (!path)
continue;
if (!submodule_has_commits(r, path, commits))
string_list_append(changed_submodule_names,
name->string);
if (submodule_has_commits(r, path, commits)) {
oid_array_clear(commits);
*name->string = '\0';
}
}
free_submodules_oids(&changed_submodules);
string_list_remove_empty_items(changed_submodule_names, 1);
argv_array_clear(&argv);
oid_array_clear(&ref_tips_before_fetch);
oid_array_clear(&ref_tips_after_fetch);
@ -1389,7 +1390,7 @@ int fetch_populated_submodules(struct repository *r,
argv_array_clear(&spf.args);
out:
string_list_clear(&spf.changed_submodule_names, 1);
free_submodules_oids(&spf.changed_submodule_names);
return spf.result;
}