Skip to content

Commit 1443ca9

Browse files
committed
Merge branch 'nd/submodule-unused-vars'
Code clean-up. * nd/submodule-unused-vars: submodule.c: remove some of the_repository references
2 parents 65f7a32 + 6245b98 commit 1443ca9

File tree

4 files changed

+38
-31
lines changed

4 files changed

+38
-31
lines changed

builtin/pull.c

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

submodule.c

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ static struct oid_array *submodule_commits(struct string_list *submodules,
694694
}
695695

696696
struct collect_changed_submodules_cb_data {
697+
struct repository *repo;
697698
struct string_list *changed;
698699
const struct object_id *commit_oid;
699700
};
@@ -733,15 +734,15 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
733734
if (!S_ISGITLINK(p->two->mode))
734735
continue;
735736

736-
submodule = submodule_from_path(the_repository,
737+
submodule = submodule_from_path(me->repo,
737738
commit_oid, p->two->path);
738739
if (submodule)
739740
name = submodule->name;
740741
else {
741742
name = default_name_or_path(p->two->path);
742743
/* make sure name does not collide with existing one */
743744
if (name)
744-
submodule = submodule_from_name(the_repository,
745+
submodule = submodule_from_name(me->repo,
745746
commit_oid, name);
746747
if (submodule) {
747748
warning("Submodule in commit %s at path: "
@@ -766,25 +767,26 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
766767
* have a corresponding 'struct oid_array' (in the 'util' field) which lists
767768
* what the submodule pointers were updated to during the change.
768769
*/
769-
static void collect_changed_submodules(struct index_state *istate,
770+
static void collect_changed_submodules(struct repository *r,
770771
struct string_list *changed,
771772
struct argv_array *argv)
772773
{
773774
struct rev_info rev;
774775
const struct commit *commit;
775776

776-
repo_init_revisions(the_repository, &rev, NULL);
777+
repo_init_revisions(r, &rev, NULL);
777778
setup_revisions(argv->argc, argv->argv, &rev, NULL);
778779
if (prepare_revision_walk(&rev))
779780
die("revision walk setup failed");
780781

781782
while ((commit = get_revision(&rev))) {
782783
struct rev_info diff_rev;
783784
struct collect_changed_submodules_cb_data data;
785+
data.repo = r;
784786
data.changed = changed;
785787
data.commit_oid = &commit->object.oid;
786788

787-
repo_init_revisions(the_repository, &diff_rev, NULL);
789+
repo_init_revisions(r, &diff_rev, NULL);
788790
diff_rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
789791
diff_rev.diffopt.format_callback = collect_changed_submodules_cb;
790792
diff_rev.diffopt.format_callback_data = &data;
@@ -816,6 +818,7 @@ static int append_oid_to_argv(const struct object_id *oid, void *data)
816818
}
817819

818820
struct has_commit_data {
821+
struct repository *repo;
819822
int result;
820823
const char *path;
821824
};
@@ -824,7 +827,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
824827
{
825828
struct has_commit_data *cb = data;
826829

827-
enum object_type type = oid_object_info(the_repository, oid, NULL);
830+
enum object_type type = oid_object_info(cb->repo, oid, NULL);
828831

829832
switch (type) {
830833
case OBJ_COMMIT:
@@ -842,9 +845,11 @@ static int check_has_commit(const struct object_id *oid, void *data)
842845
}
843846
}
844847

845-
static int submodule_has_commits(const char *path, struct oid_array *commits)
848+
static int submodule_has_commits(struct repository *r,
849+
const char *path,
850+
struct oid_array *commits)
846851
{
847-
struct has_commit_data has_commit = { 1, path };
852+
struct has_commit_data has_commit = { r, 1, path };
848853

849854
/*
850855
* Perform a cheap, but incorrect check for the existence of 'commits'.
@@ -887,9 +892,11 @@ static int submodule_has_commits(const char *path, struct oid_array *commits)
887892
return has_commit.result;
888893
}
889894

890-
static int submodule_needs_pushing(const char *path, struct oid_array *commits)
895+
static int submodule_needs_pushing(struct repository *r,
896+
const char *path,
897+
struct oid_array *commits)
891898
{
892-
if (!submodule_has_commits(path, commits))
899+
if (!submodule_has_commits(r, path, commits))
893900
/*
894901
* NOTE: We do consider it safe to return "no" here. The
895902
* correct answer would be "We do not know" instead of
@@ -931,7 +938,7 @@ static int submodule_needs_pushing(const char *path, struct oid_array *commits)
931938
return 0;
932939
}
933940

934-
int find_unpushed_submodules(struct index_state *istate,
941+
int find_unpushed_submodules(struct repository *r,
935942
struct oid_array *commits,
936943
const char *remotes_name,
937944
struct string_list *needs_pushing)
@@ -946,14 +953,14 @@ int find_unpushed_submodules(struct index_state *istate,
946953
argv_array_push(&argv, "--not");
947954
argv_array_pushf(&argv, "--remotes=%s", remotes_name);
948955

949-
collect_changed_submodules(istate, &submodules, &argv);
956+
collect_changed_submodules(r, &submodules, &argv);
950957

951958
for_each_string_list_item(name, &submodules) {
952959
struct oid_array *commits = name->util;
953960
const struct submodule *submodule;
954961
const char *path = NULL;
955962

956-
submodule = submodule_from_name(the_repository, &null_oid, name->string);
963+
submodule = submodule_from_name(r, &null_oid, name->string);
957964
if (submodule)
958965
path = submodule->path;
959966
else
@@ -962,7 +969,7 @@ int find_unpushed_submodules(struct index_state *istate,
962969
if (!path)
963970
continue;
964971

965-
if (submodule_needs_pushing(path, commits))
972+
if (submodule_needs_pushing(r, path, commits))
966973
string_list_insert(needs_pushing, path);
967974
}
968975

@@ -1047,7 +1054,7 @@ static void submodule_push_check(const char *path, const char *head,
10471054
die("process for submodule '%s' failed", path);
10481055
}
10491056

1050-
int push_unpushed_submodules(struct index_state *istate,
1057+
int push_unpushed_submodules(struct repository *r,
10511058
struct oid_array *commits,
10521059
const struct remote *remote,
10531060
const struct refspec *rs,
@@ -1057,7 +1064,7 @@ int push_unpushed_submodules(struct index_state *istate,
10571064
int i, ret = 1;
10581065
struct string_list needs_pushing = STRING_LIST_INIT_DUP;
10591066

1060-
if (!find_unpushed_submodules(istate, commits,
1067+
if (!find_unpushed_submodules(r, commits,
10611068
remote->name, &needs_pushing))
10621069
return 1;
10631070

@@ -1115,14 +1122,14 @@ void check_for_new_submodule_commits(struct object_id *oid)
11151122
oid_array_append(&ref_tips_after_fetch, oid);
11161123
}
11171124

1118-
static void calculate_changed_submodule_paths(struct index_state *istate)
1125+
static void calculate_changed_submodule_paths(struct repository *r)
11191126
{
11201127
struct argv_array argv = ARGV_ARRAY_INIT;
11211128
struct string_list changed_submodules = STRING_LIST_INIT_DUP;
11221129
const struct string_list_item *name;
11231130

11241131
/* No need to check if there are no submodules configured */
1125-
if (!submodule_from_path(the_repository, NULL, NULL))
1132+
if (!submodule_from_path(r, NULL, NULL))
11261133
return;
11271134

11281135
argv_array_push(&argv, "--"); /* argv[0] program name */
@@ -1136,14 +1143,14 @@ static void calculate_changed_submodule_paths(struct index_state *istate)
11361143
* Collect all submodules (whether checked out or not) for which new
11371144
* commits have been recorded upstream in "changed_submodule_names".
11381145
*/
1139-
collect_changed_submodules(istate, &changed_submodules, &argv);
1146+
collect_changed_submodules(r, &changed_submodules, &argv);
11401147

11411148
for_each_string_list_item(name, &changed_submodules) {
11421149
struct oid_array *commits = name->util;
11431150
const struct submodule *submodule;
11441151
const char *path = NULL;
11451152

1146-
submodule = submodule_from_name(the_repository, &null_oid, name->string);
1153+
submodule = submodule_from_name(r, &null_oid, name->string);
11471154
if (submodule)
11481155
path = submodule->path;
11491156
else
@@ -1152,7 +1159,7 @@ static void calculate_changed_submodule_paths(struct index_state *istate)
11521159
if (!path)
11531160
continue;
11541161

1155-
if (!submodule_has_commits(path, commits))
1162+
if (!submodule_has_commits(r, path, commits))
11561163
string_list_append(&changed_submodule_names, name->string);
11571164
}
11581165

@@ -1163,7 +1170,7 @@ static void calculate_changed_submodule_paths(struct index_state *istate)
11631170
initialized_fetch_ref_tips = 0;
11641171
}
11651172

1166-
int submodule_touches_in_range(struct index_state *istate,
1173+
int submodule_touches_in_range(struct repository *r,
11671174
struct object_id *excl_oid,
11681175
struct object_id *incl_oid)
11691176
{
@@ -1172,7 +1179,7 @@ int submodule_touches_in_range(struct index_state *istate,
11721179
int ret;
11731180

11741181
/* No need to check if there are no submodules configured */
1175-
if (!submodule_from_path(the_repository, NULL, NULL))
1182+
if (!submodule_from_path(r, NULL, NULL))
11761183
return 0;
11771184

11781185
argv_array_push(&args, "--"); /* args[0] program name */
@@ -1182,7 +1189,7 @@ int submodule_touches_in_range(struct index_state *istate,
11821189
argv_array_push(&args, oid_to_hex(excl_oid));
11831190
}
11841191

1185-
collect_changed_submodules(istate, &subs, &args);
1192+
collect_changed_submodules(r, &subs, &args);
11861193
ret = subs.nr;
11871194

11881195
argv_array_clear(&args);
@@ -1352,7 +1359,7 @@ int fetch_populated_submodules(struct repository *r,
13521359
argv_array_push(&spf.args, "--recurse-submodules-default");
13531360
/* default value, "--submodule-prefix" and its value are added later */
13541361

1355-
calculate_changed_submodule_paths(r->index);
1362+
calculate_changed_submodule_paths(r);
13561363
run_processes_parallel(max_parallel_jobs,
13571364
get_next_submodule,
13581365
fetch_start_failure,

submodule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ 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 index_state *istate,
105+
int submodule_touches_in_range(struct repository *r,
106106
struct object_id *a,
107107
struct object_id *b);
108-
int find_unpushed_submodules(struct index_state *istate,
108+
int find_unpushed_submodules(struct repository *r,
109109
struct oid_array *commits,
110110
const char *remotes_name,
111111
struct string_list *needs_pushing);
112112
struct refspec;
113-
int push_unpushed_submodules(struct index_state *istate,
113+
int push_unpushed_submodules(struct repository *r,
114114
struct oid_array *commits,
115115
const struct remote *remote,
116116
const struct refspec *rs,

transport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ int transport_push(struct transport *transport,
11721172
oid_array_append(&commits,
11731173
&ref->new_oid);
11741174

1175-
if (!push_unpushed_submodules(&the_index,
1175+
if (!push_unpushed_submodules(the_repository,
11761176
&commits,
11771177
transport->remote,
11781178
rs,
@@ -1197,7 +1197,7 @@ int transport_push(struct transport *transport,
11971197
oid_array_append(&commits,
11981198
&ref->new_oid);
11991199

1200-
if (find_unpushed_submodules(&the_index,
1200+
if (find_unpushed_submodules(the_repository,
12011201
&commits,
12021202
transport->remote->name,
12031203
&needs_pushing)) {

0 commit comments

Comments
 (0)