Skip to content

Commit 16dd6fe

Browse files
stefanbellergitster
authored andcommitted
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>
1 parent 08a297b commit 16dd6fe

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

submodule.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "commit-reach.h"
2626

2727
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
28-
static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP;
2928
static int initialized_fetch_ref_tips;
3029
static struct oid_array ref_tips_before_fetch;
3130
static struct oid_array ref_tips_after_fetch;
@@ -1136,7 +1135,8 @@ void check_for_new_submodule_commits(struct object_id *oid)
11361135
oid_array_append(&ref_tips_after_fetch, oid);
11371136
}
11381137

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)
11401140
{
11411141
struct argv_array argv = ARGV_ARRAY_INIT;
11421142
struct string_list changed_submodules = STRING_LIST_INIT_DUP;
@@ -1174,7 +1174,8 @@ static void calculate_changed_submodule_paths(struct repository *r)
11741174
continue;
11751175

11761176
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);
11781179
}
11791180

11801181
free_submodules_oids(&changed_submodules);
@@ -1221,8 +1222,10 @@ struct submodule_parallel_fetch {
12211222
int default_option;
12221223
int quiet;
12231224
int result;
1225+
1226+
struct string_list changed_submodule_names;
12241227
};
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 }
12261229

12271230
static int get_fetch_recurse_config(const struct submodule *submodule,
12281231
struct submodule_parallel_fetch *spf)
@@ -1284,7 +1287,7 @@ static int get_next_submodule(struct child_process *cp,
12841287
case RECURSE_SUBMODULES_ON_DEMAND:
12851288
if (!submodule ||
12861289
!string_list_lookup(
1287-
&changed_submodule_names,
1290+
&spf->changed_submodule_names,
12881291
submodule->name))
12891292
continue;
12901293
default_argv = "on-demand";
@@ -1376,8 +1379,8 @@ int fetch_populated_submodules(struct repository *r,
13761379
argv_array_push(&spf.args, "--recurse-submodules-default");
13771380
/* default value, "--submodule-prefix" and its value are added later */
13781381

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);
13811384
run_processes_parallel(max_parallel_jobs,
13821385
get_next_submodule,
13831386
fetch_start_failure,
@@ -1386,7 +1389,7 @@ int fetch_populated_submodules(struct repository *r,
13861389

13871390
argv_array_clear(&spf.args);
13881391
out:
1389-
string_list_clear(&changed_submodule_names, 1);
1392+
string_list_clear(&spf.changed_submodule_names, 1);
13901393
return spf.result;
13911394
}
13921395

0 commit comments

Comments
 (0)