Skip to content

Commit 174d131

Browse files
pcloudsgitster
authored andcommitted
submodule.c: remove implicit dependency on the_index
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 80e0385 commit 174d131

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

builtin/pull.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
944944
int ret = 0;
945945
if ((recurse_submodules == RECURSE_SUBMODULES_ON ||
946946
recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) &&
947-
submodule_touches_in_range(&rebase_fork_point, &curr_head))
947+
submodule_touches_in_range(&the_index, &rebase_fork_point, &curr_head))
948948
die(_("cannot rebase with locally recorded submodule modifications"));
949949
if (!autostash) {
950950
struct commit_list *list = NULL;

submodule.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,8 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
766766
* have a corresponding 'struct oid_array' (in the 'util' field) which lists
767767
* what the submodule pointers were updated to during the change.
768768
*/
769-
static void collect_changed_submodules(struct string_list *changed,
769+
static void collect_changed_submodules(struct index_state *istate,
770+
struct string_list *changed,
770771
struct argv_array *argv)
771772
{
772773
struct rev_info rev;
@@ -930,8 +931,10 @@ static int submodule_needs_pushing(const char *path, struct oid_array *commits)
930931
return 0;
931932
}
932933

933-
int find_unpushed_submodules(struct oid_array *commits,
934-
const char *remotes_name, struct string_list *needs_pushing)
934+
int find_unpushed_submodules(struct index_state *istate,
935+
struct oid_array *commits,
936+
const char *remotes_name,
937+
struct string_list *needs_pushing)
935938
{
936939
struct string_list submodules = STRING_LIST_INIT_DUP;
937940
struct string_list_item *name;
@@ -943,7 +946,7 @@ int find_unpushed_submodules(struct oid_array *commits,
943946
argv_array_push(&argv, "--not");
944947
argv_array_pushf(&argv, "--remotes=%s", remotes_name);
945948

946-
collect_changed_submodules(&submodules, &argv);
949+
collect_changed_submodules(istate, &submodules, &argv);
947950

948951
for_each_string_list_item(name, &submodules) {
949952
struct oid_array *commits = name->util;
@@ -1044,7 +1047,8 @@ static void submodule_push_check(const char *path, const char *head,
10441047
die("process for submodule '%s' failed", path);
10451048
}
10461049

1047-
int push_unpushed_submodules(struct oid_array *commits,
1050+
int push_unpushed_submodules(struct index_state *istate,
1051+
struct oid_array *commits,
10481052
const struct remote *remote,
10491053
const struct refspec *rs,
10501054
const struct string_list *push_options,
@@ -1053,7 +1057,8 @@ int push_unpushed_submodules(struct oid_array *commits,
10531057
int i, ret = 1;
10541058
struct string_list needs_pushing = STRING_LIST_INIT_DUP;
10551059

1056-
if (!find_unpushed_submodules(commits, remote->name, &needs_pushing))
1060+
if (!find_unpushed_submodules(istate, commits,
1061+
remote->name, &needs_pushing))
10571062
return 1;
10581063

10591064
/*
@@ -1110,7 +1115,7 @@ void check_for_new_submodule_commits(struct object_id *oid)
11101115
oid_array_append(&ref_tips_after_fetch, oid);
11111116
}
11121117

1113-
static void calculate_changed_submodule_paths(void)
1118+
static void calculate_changed_submodule_paths(struct index_state *istate)
11141119
{
11151120
struct argv_array argv = ARGV_ARRAY_INIT;
11161121
struct string_list changed_submodules = STRING_LIST_INIT_DUP;
@@ -1131,7 +1136,7 @@ static void calculate_changed_submodule_paths(void)
11311136
* Collect all submodules (whether checked out or not) for which new
11321137
* commits have been recorded upstream in "changed_submodule_names".
11331138
*/
1134-
collect_changed_submodules(&changed_submodules, &argv);
1139+
collect_changed_submodules(istate, &changed_submodules, &argv);
11351140

11361141
for_each_string_list_item(name, &changed_submodules) {
11371142
struct oid_array *commits = name->util;
@@ -1158,7 +1163,8 @@ static void calculate_changed_submodule_paths(void)
11581163
initialized_fetch_ref_tips = 0;
11591164
}
11601165

1161-
int submodule_touches_in_range(struct object_id *excl_oid,
1166+
int submodule_touches_in_range(struct index_state *istate,
1167+
struct object_id *excl_oid,
11621168
struct object_id *incl_oid)
11631169
{
11641170
struct string_list subs = STRING_LIST_INIT_DUP;
@@ -1176,7 +1182,7 @@ int submodule_touches_in_range(struct object_id *excl_oid,
11761182
argv_array_push(&args, oid_to_hex(excl_oid));
11771183
}
11781184

1179-
collect_changed_submodules(&subs, &args);
1185+
collect_changed_submodules(istate, &subs, &args);
11801186
ret = subs.nr;
11811187

11821188
argv_array_clear(&args);
@@ -1346,7 +1352,7 @@ int fetch_populated_submodules(struct repository *r,
13461352
argv_array_push(&spf.args, "--recurse-submodules-default");
13471353
/* default value, "--submodule-prefix" and its value are added later */
13481354

1349-
calculate_changed_submodule_paths();
1355+
calculate_changed_submodule_paths(r->index);
13501356
run_processes_parallel(max_parallel_jobs,
13511357
get_next_submodule,
13521358
fetch_start_failure,

submodule.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,16 @@ int add_submodule_odb(const char *path);
102102
* Checks if there are submodule changes in a..b. If a is the null OID,
103103
* checks b and all its ancestors instead.
104104
*/
105-
int submodule_touches_in_range(struct object_id *a,
105+
int submodule_touches_in_range(struct index_state *istate,
106+
struct object_id *a,
106107
struct object_id *b);
107-
int find_unpushed_submodules(struct oid_array *commits,
108+
int find_unpushed_submodules(struct index_state *istate,
109+
struct oid_array *commits,
108110
const char *remotes_name,
109111
struct string_list *needs_pushing);
110112
struct refspec;
111-
int push_unpushed_submodules(struct oid_array *commits,
113+
int push_unpushed_submodules(struct index_state *istate,
114+
struct oid_array *commits,
112115
const struct remote *remote,
113116
const struct refspec *rs,
114117
const struct string_list *push_options,

transport.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,8 @@ int transport_push(struct transport *transport,
11391139
oid_array_append(&commits,
11401140
&ref->new_oid);
11411141

1142-
if (!push_unpushed_submodules(&commits,
1142+
if (!push_unpushed_submodules(&the_index,
1143+
&commits,
11431144
transport->remote,
11441145
rs,
11451146
transport->push_options,
@@ -1163,8 +1164,10 @@ int transport_push(struct transport *transport,
11631164
oid_array_append(&commits,
11641165
&ref->new_oid);
11651166

1166-
if (find_unpushed_submodules(&commits, transport->remote->name,
1167-
&needs_pushing)) {
1167+
if (find_unpushed_submodules(&the_index,
1168+
&commits,
1169+
transport->remote->name,
1170+
&needs_pushing)) {
11681171
oid_array_clear(&commits);
11691172
die_with_unpushed_submodules(&needs_pushing);
11701173
}

0 commit comments

Comments
 (0)