submodule.c: tighten scope of changed_submodule_names struct
The `changed_submodule_names` are only used for fetching, so let's make it part of the struct that is passed around for fetching submodules. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Nov 28, 2018 at 16:27 UTC
16dd6fe133cc3693f0daad0d10c4f65713e36de4
1 file changed
+11
-8
submodule.c
+11
-8
@@ -25,7 +25,6 @@
25
#include "commit-reach.h"
26
27
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
28
-static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP;
28
static int initialized_fetch_ref_tips;
29
static struct oid_array ref_tips_before_fetch;
30
static struct oid_array ref_tips_after_fetch;
@@ -1136,7 +1135,8 @@ void check_for_new_submodule_commits(struct object_id *oid)
1135
oid_array_append(&ref_tips_after_fetch, oid);
1136
}
1137
1139
-static void calculate_changed_submodule_paths(struct repository *r)
1138
+static void calculate_changed_submodule_paths(struct repository *r,
1139
+ struct string_list *changed_submodule_names)
1140
{
1141
struct argv_array argv = ARGV_ARRAY_INIT;
1142
struct string_list changed_submodules = STRING_LIST_INIT_DUP;
@@ -1174,7 +1174,8 @@ static void calculate_changed_submodule_paths(struct repository *r)
1174
continue;
1175
1176
if (!submodule_has_commits(r, path, commits))
1177
- string_list_append(&changed_submodule_names, name->string);
1177
+ string_list_append(changed_submodule_names,
1178
+ name->string);
1179
}
1180
1181
free_submodules_oids(&changed_submodules);
@@ -1221,8 +1222,10 @@ struct submodule_parallel_fetch {
1222
int default_option;
1223
int quiet;
1224
int result;
1225
+
1226
+ struct string_list changed_submodule_names;
1227
};
1225
-#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0}
1228
+#define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0, STRING_LIST_INIT_DUP }
1229
1230
static int get_fetch_recurse_config(const struct submodule *submodule,
1231
struct submodule_parallel_fetch *spf)
@@ -1284,7 +1287,7 @@ static int get_next_submodule(struct child_process *cp,
1287
case RECURSE_SUBMODULES_ON_DEMAND:
1288
if (!submodule ||
1289
!string_list_lookup(
1287
- &changed_submodule_names,
1290
+ &spf->changed_submodule_names,
1291
submodule->name))
1292
continue;
1293
default_argv = "on-demand";
@@ -1376,8 +1379,8 @@ int fetch_populated_submodules(struct repository *r,
1379
argv_array_push(&spf.args, "--recurse-submodules-default");
1380
/* default value, "--submodule-prefix" and its value are added later */
1381
1379
- calculate_changed_submodule_paths(r);
1380
- string_list_sort(&changed_submodule_names);
1382
+ calculate_changed_submodule_paths(r, &spf.changed_submodule_names);
1383
+ string_list_sort(&spf.changed_submodule_names);
1384
run_processes_parallel(max_parallel_jobs,
1385
get_next_submodule,
1386
fetch_start_failure,
@@ -1386,7 +1389,7 @@ int fetch_populated_submodules(struct repository *r,
1389
1390
argv_array_clear(&spf.args);
1391
out:
1389
- string_list_clear(&changed_submodule_names, 1);
1392
+ string_list_clear(&spf.changed_submodule_names, 1);
1393
return spf.result;
1394
}
1395