summaryrefslogtreecommitdiff
path: root/submodule.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-11-29 00:27:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-12-05 02:42:31 (GMT)
commit16dd6fe133cc3693f0daad0d10c4f65713e36de4 (patch)
tree31da19364971b6caf4d3ccd1f37891e158c0bc40 /submodule.c
parent08a297bd4996480f0b03830058f413bb24f0d37c (diff)
downloadgit-16dd6fe133cc3693f0daad0d10c4f65713e36de4.zip
git-16dd6fe133cc3693f0daad0d10c4f65713e36de4.tar.gz
git-16dd6fe133cc3693f0daad0d10c4f65713e36de4.tar.bz2
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>
Diffstat (limited to 'submodule.c')
-rw-r--r--submodule.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/submodule.c b/submodule.c
index 3c388f8..f93f0af 100644
--- a/submodule.c
+++ b/submodule.c
@@ -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)
@@ -1284,7 +1287,7 @@ static int get_next_submodule(struct child_process *cp,
case RECURSE_SUBMODULES_ON_DEMAND:
if (!submodule ||
!string_list_lookup(
- &changed_submodule_names,
+ &spf->changed_submodule_names,
submodule->name))
continue;
default_argv = "on-demand";
@@ -1376,8 +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);
- string_list_sort(&changed_submodule_names);
+ 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,
@@ -1386,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;
}