submodule.c: remove implicit dependency on the_index
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Sep 21, 2018 at 17:57 UTC
174d131fc92b72a04c3da4259dd8bf356e07fc49
4 files changed
+30
-18
builtin/pull.c
+1
-1
@@ -944,7 +944,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
944
int ret = 0;
945
if ((recurse_submodules == RECURSE_SUBMODULES_ON ||
946
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))
948
die(_("cannot rebase with locally recorded submodule modifications"));
949
if (!autostash) {
950
struct commit_list *list = NULL;
submodule.c
+17
-11
@@ -766,7 +766,8 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
766
* have a corresponding 'struct oid_array' (in the 'util' field) which lists
767
* what the submodule pointers were updated to during the change.
768
*/
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,
771
struct argv_array *argv)
772
{
773
struct rev_info rev;
@@ -930,8 +931,10 @@ static int submodule_needs_pushing(const char *path, struct oid_array *commits)
931
return 0;
932
}
933
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)
938
{
939
struct string_list submodules = STRING_LIST_INIT_DUP;
940
struct string_list_item *name;
@@ -943,7 +946,7 @@ int find_unpushed_submodules(struct oid_array *commits,
946
argv_array_push(&argv, "--not");
947
argv_array_pushf(&argv, "--remotes=%s", remotes_name);
948
946
- collect_changed_submodules(&submodules, &argv);
949
+ collect_changed_submodules(istate, &submodules, &argv);
950
951
for_each_string_list_item(name, &submodules) {
952
struct oid_array *commits = name->util;
@@ -1044,7 +1047,8 @@ static void submodule_push_check(const char *path, const char *head,
1047
die("process for submodule '%s' failed", path);
1048
}
1049
1047
-int push_unpushed_submodules(struct oid_array *commits,
1050
+int push_unpushed_submodules(struct index_state *istate,
1051
+ struct oid_array *commits,
1052
const struct remote *remote,
1053
const struct refspec *rs,
1054
const struct string_list *push_options,
@@ -1053,7 +1057,8 @@ int push_unpushed_submodules(struct oid_array *commits,
1057
int i, ret = 1;
1058
struct string_list needs_pushing = STRING_LIST_INIT_DUP;
1059
1056
- if (!find_unpushed_submodules(commits, remote->name, &needs_pushing))
1060
+ if (!find_unpushed_submodules(istate, commits,
1061
+ remote->name, &needs_pushing))
1062
return 1;
1063
1064
/*
@@ -1110,7 +1115,7 @@ void check_for_new_submodule_commits(struct object_id *oid)
1115
oid_array_append(&ref_tips_after_fetch, oid);
1116
}
1117
1113
-static void calculate_changed_submodule_paths(void)
1118
+static void calculate_changed_submodule_paths(struct index_state *istate)
1119
{
1120
struct argv_array argv = ARGV_ARRAY_INIT;
1121
struct string_list changed_submodules = STRING_LIST_INIT_DUP;
@@ -1131,7 +1136,7 @@ static void calculate_changed_submodule_paths(void)
1136
* Collect all submodules (whether checked out or not) for which new
1137
* commits have been recorded upstream in "changed_submodule_names".
1138
*/
1134
- collect_changed_submodules(&changed_submodules, &argv);
1139
+ collect_changed_submodules(istate, &changed_submodules, &argv);
1140
1141
for_each_string_list_item(name, &changed_submodules) {
1142
struct oid_array *commits = name->util;
@@ -1158,7 +1163,8 @@ static void calculate_changed_submodule_paths(void)
1163
initialized_fetch_ref_tips = 0;
1164
}
1165
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,
1168
struct object_id *incl_oid)
1169
{
1170
struct string_list subs = STRING_LIST_INIT_DUP;
@@ -1176,7 +1182,7 @@ int submodule_touches_in_range(struct object_id *excl_oid,
1182
argv_array_push(&args, oid_to_hex(excl_oid));
1183
}
1184
1179
- collect_changed_submodules(&subs, &args);
1185
+ collect_changed_submodules(istate, &subs, &args);
1186
ret = subs.nr;
1187
1188
argv_array_clear(&args);
@@ -1346,7 +1352,7 @@ int fetch_populated_submodules(struct repository *r,
1352
argv_array_push(&spf.args, "--recurse-submodules-default");
1353
/* default value, "--submodule-prefix" and its value are added later */
1354
1349
- calculate_changed_submodule_paths();
1355
+ calculate_changed_submodule_paths(r->index);
1356
run_processes_parallel(max_parallel_jobs,
1357
get_next_submodule,
1358
fetch_start_failure,
submodule.h
+6
-3
@@ -102,13 +102,16 @@ int add_submodule_odb(const char *path);
102
* Checks if there are submodule changes in a..b. If a is the null OID,
103
* checks b and all its ancestors instead.
104
*/
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,
107
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,
110
const char *remotes_name,
111
struct string_list *needs_pushing);
112
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,
115
const struct remote *remote,
116
const struct refspec *rs,
117
const struct string_list *push_options,
transport.c
+6
-3
@@ -1139,7 +1139,8 @@ int transport_push(struct transport *transport,
1139
oid_array_append(&commits,
1140
&ref->new_oid);
1141
1142
- if (!push_unpushed_submodules(&commits,
1142
+ if (!push_unpushed_submodules(&the_index,
1143
+ &commits,
1144
transport->remote,
1145
rs,
1146
transport->push_options,
@@ -1163,8 +1164,10 @@ int transport_push(struct transport *transport,
1164
oid_array_append(&commits,
1165
&ref->new_oid);
1166
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)) {
1171
oid_array_clear(&commits);
1172
die_with_unpushed_submodules(&needs_pushing);
1173
}