]> git.ipfire.org Git - thirdparty/git.git/blobdiff - submodule.c
submodule.c: tighten scope of changed_submodule_names struct
[thirdparty/git.git] / submodule.c
index 6415cc55807c7ed9ee4cbcaa57f41a5804b6e854..f93f0aff82dcc1a75f9a40d8e5197a43c3aa17bc 100644 (file)
@@ -25,7 +25,6 @@
 #include "commit-reach.h"
 
 static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
-static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP;
 static int initialized_fetch_ref_tips;
 static struct oid_array ref_tips_before_fetch;
 static struct oid_array ref_tips_after_fetch;
@@ -1136,7 +1135,8 @@ void check_for_new_submodule_commits(struct object_id *oid)
        oid_array_append(&ref_tips_after_fetch, oid);
 }
 
-static void calculate_changed_submodule_paths(struct repository *r)
+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;
@@ -1174,7 +1174,8 @@ static void calculate_changed_submodule_paths(struct repository *r)
                        continue;
 
                if (!submodule_has_commits(r, path, commits))
-                       string_list_append(&changed_submodule_names, name->string);
+                       string_list_append(changed_submodule_names,
+                                          name->string);
        }
 
        free_submodules_oids(&changed_submodules);
@@ -1221,8 +1222,10 @@ struct submodule_parallel_fetch {
        int default_option;
        int quiet;
        int result;
+
+       struct string_list changed_submodule_names;
 };
-#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0}
+#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, STRING_LIST_INIT_DUP }
 
 static int get_fetch_recurse_config(const struct submodule *submodule,
                                    struct submodule_parallel_fetch *spf)
@@ -1271,7 +1274,8 @@ static int get_next_submodule(struct child_process *cp,
                if (!submodule) {
                        const char *name = default_name_or_path(ce->name);
                        if (name) {
-                               default_submodule.path = default_submodule.name = name;
+                               default_submodule.path = name;
+                               default_submodule.name = name;
                                submodule = &default_submodule;
                        }
                }
@@ -1281,8 +1285,10 @@ static int get_next_submodule(struct child_process *cp,
                default:
                case RECURSE_SUBMODULES_DEFAULT:
                case RECURSE_SUBMODULES_ON_DEMAND:
-                       if (!submodule || !unsorted_string_list_lookup(&changed_submodule_names,
-                                                        submodule->name))
+                       if (!submodule ||
+                           !string_list_lookup(
+                                       &spf->changed_submodule_names,
+                                       submodule->name))
                                continue;
                        default_argv = "on-demand";
                        break;
@@ -1373,7 +1379,8 @@ int fetch_populated_submodules(struct repository *r,
        argv_array_push(&spf.args, "--recurse-submodules-default");
        /* default value, "--submodule-prefix" and its value are added later */
 
-       calculate_changed_submodule_paths(r);
+       calculate_changed_submodule_paths(r, &spf.changed_submodule_names);
+       string_list_sort(&spf.changed_submodule_names);
        run_processes_parallel(max_parallel_jobs,
                               get_next_submodule,
                               fetch_start_failure,
@@ -1382,7 +1389,7 @@ int fetch_populated_submodules(struct repository *r,
 
        argv_array_clear(&spf.args);
 out:
-       string_list_clear(&changed_submodule_names, 1);
+       string_list_clear(&spf.changed_submodule_names, 1);
        return spf.result;
 }