@@ -694,6 +694,7 @@ static struct oid_array *submodule_commits(struct string_list *submodules,
694
694
}
695
695
696
696
struct collect_changed_submodules_cb_data {
697
+ struct repository * repo ;
697
698
struct string_list * changed ;
698
699
const struct object_id * commit_oid ;
699
700
};
@@ -733,15 +734,15 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
733
734
if (!S_ISGITLINK (p -> two -> mode ))
734
735
continue ;
735
736
736
- submodule = submodule_from_path (the_repository ,
737
+ submodule = submodule_from_path (me -> repo ,
737
738
commit_oid , p -> two -> path );
738
739
if (submodule )
739
740
name = submodule -> name ;
740
741
else {
741
742
name = default_name_or_path (p -> two -> path );
742
743
/* make sure name does not collide with existing one */
743
744
if (name )
744
- submodule = submodule_from_name (the_repository ,
745
+ submodule = submodule_from_name (me -> repo ,
745
746
commit_oid , name );
746
747
if (submodule ) {
747
748
warning ("Submodule in commit %s at path: "
@@ -766,25 +767,26 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
766
767
* have a corresponding 'struct oid_array' (in the 'util' field) which lists
767
768
* what the submodule pointers were updated to during the change.
768
769
*/
769
- static void collect_changed_submodules (struct index_state * istate ,
770
+ static void collect_changed_submodules (struct repository * r ,
770
771
struct string_list * changed ,
771
772
struct argv_array * argv )
772
773
{
773
774
struct rev_info rev ;
774
775
const struct commit * commit ;
775
776
776
- repo_init_revisions (the_repository , & rev , NULL );
777
+ repo_init_revisions (r , & rev , NULL );
777
778
setup_revisions (argv -> argc , argv -> argv , & rev , NULL );
778
779
if (prepare_revision_walk (& rev ))
779
780
die ("revision walk setup failed" );
780
781
781
782
while ((commit = get_revision (& rev ))) {
782
783
struct rev_info diff_rev ;
783
784
struct collect_changed_submodules_cb_data data ;
785
+ data .repo = r ;
784
786
data .changed = changed ;
785
787
data .commit_oid = & commit -> object .oid ;
786
788
787
- repo_init_revisions (the_repository , & diff_rev , NULL );
789
+ repo_init_revisions (r , & diff_rev , NULL );
788
790
diff_rev .diffopt .output_format |= DIFF_FORMAT_CALLBACK ;
789
791
diff_rev .diffopt .format_callback = collect_changed_submodules_cb ;
790
792
diff_rev .diffopt .format_callback_data = & data ;
@@ -816,6 +818,7 @@ static int append_oid_to_argv(const struct object_id *oid, void *data)
816
818
}
817
819
818
820
struct has_commit_data {
821
+ struct repository * repo ;
819
822
int result ;
820
823
const char * path ;
821
824
};
@@ -824,7 +827,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
824
827
{
825
828
struct has_commit_data * cb = data ;
826
829
827
- enum object_type type = oid_object_info (the_repository , oid , NULL );
830
+ enum object_type type = oid_object_info (cb -> repo , oid , NULL );
828
831
829
832
switch (type ) {
830
833
case OBJ_COMMIT :
@@ -842,9 +845,11 @@ static int check_has_commit(const struct object_id *oid, void *data)
842
845
}
843
846
}
844
847
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 )
846
851
{
847
- struct has_commit_data has_commit = { 1 , path };
852
+ struct has_commit_data has_commit = { r , 1 , path };
848
853
849
854
/*
850
855
* 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)
887
892
return has_commit .result ;
888
893
}
889
894
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 )
891
898
{
892
- if (!submodule_has_commits (path , commits ))
899
+ if (!submodule_has_commits (r , path , commits ))
893
900
/*
894
901
* NOTE: We do consider it safe to return "no" here. The
895
902
* 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)
931
938
return 0 ;
932
939
}
933
940
934
- int find_unpushed_submodules (struct index_state * istate ,
941
+ int find_unpushed_submodules (struct repository * r ,
935
942
struct oid_array * commits ,
936
943
const char * remotes_name ,
937
944
struct string_list * needs_pushing )
@@ -946,14 +953,14 @@ int find_unpushed_submodules(struct index_state *istate,
946
953
argv_array_push (& argv , "--not" );
947
954
argv_array_pushf (& argv , "--remotes=%s" , remotes_name );
948
955
949
- collect_changed_submodules (istate , & submodules , & argv );
956
+ collect_changed_submodules (r , & submodules , & argv );
950
957
951
958
for_each_string_list_item (name , & submodules ) {
952
959
struct oid_array * commits = name -> util ;
953
960
const struct submodule * submodule ;
954
961
const char * path = NULL ;
955
962
956
- submodule = submodule_from_name (the_repository , & null_oid , name -> string );
963
+ submodule = submodule_from_name (r , & null_oid , name -> string );
957
964
if (submodule )
958
965
path = submodule -> path ;
959
966
else
@@ -962,7 +969,7 @@ int find_unpushed_submodules(struct index_state *istate,
962
969
if (!path )
963
970
continue ;
964
971
965
- if (submodule_needs_pushing (path , commits ))
972
+ if (submodule_needs_pushing (r , path , commits ))
966
973
string_list_insert (needs_pushing , path );
967
974
}
968
975
@@ -1047,7 +1054,7 @@ static void submodule_push_check(const char *path, const char *head,
1047
1054
die ("process for submodule '%s' failed" , path );
1048
1055
}
1049
1056
1050
- int push_unpushed_submodules (struct index_state * istate ,
1057
+ int push_unpushed_submodules (struct repository * r ,
1051
1058
struct oid_array * commits ,
1052
1059
const struct remote * remote ,
1053
1060
const struct refspec * rs ,
@@ -1057,7 +1064,7 @@ int push_unpushed_submodules(struct index_state *istate,
1057
1064
int i , ret = 1 ;
1058
1065
struct string_list needs_pushing = STRING_LIST_INIT_DUP ;
1059
1066
1060
- if (!find_unpushed_submodules (istate , commits ,
1067
+ if (!find_unpushed_submodules (r , commits ,
1061
1068
remote -> name , & needs_pushing ))
1062
1069
return 1 ;
1063
1070
@@ -1115,14 +1122,14 @@ void check_for_new_submodule_commits(struct object_id *oid)
1115
1122
oid_array_append (& ref_tips_after_fetch , oid );
1116
1123
}
1117
1124
1118
- static void calculate_changed_submodule_paths (struct index_state * istate )
1125
+ static void calculate_changed_submodule_paths (struct repository * r )
1119
1126
{
1120
1127
struct argv_array argv = ARGV_ARRAY_INIT ;
1121
1128
struct string_list changed_submodules = STRING_LIST_INIT_DUP ;
1122
1129
const struct string_list_item * name ;
1123
1130
1124
1131
/* 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 ))
1126
1133
return ;
1127
1134
1128
1135
argv_array_push (& argv , "--" ); /* argv[0] program name */
@@ -1136,14 +1143,14 @@ static void calculate_changed_submodule_paths(struct index_state *istate)
1136
1143
* Collect all submodules (whether checked out or not) for which new
1137
1144
* commits have been recorded upstream in "changed_submodule_names".
1138
1145
*/
1139
- collect_changed_submodules (istate , & changed_submodules , & argv );
1146
+ collect_changed_submodules (r , & changed_submodules , & argv );
1140
1147
1141
1148
for_each_string_list_item (name , & changed_submodules ) {
1142
1149
struct oid_array * commits = name -> util ;
1143
1150
const struct submodule * submodule ;
1144
1151
const char * path = NULL ;
1145
1152
1146
- submodule = submodule_from_name (the_repository , & null_oid , name -> string );
1153
+ submodule = submodule_from_name (r , & null_oid , name -> string );
1147
1154
if (submodule )
1148
1155
path = submodule -> path ;
1149
1156
else
@@ -1152,7 +1159,7 @@ static void calculate_changed_submodule_paths(struct index_state *istate)
1152
1159
if (!path )
1153
1160
continue ;
1154
1161
1155
- if (!submodule_has_commits (path , commits ))
1162
+ if (!submodule_has_commits (r , path , commits ))
1156
1163
string_list_append (& changed_submodule_names , name -> string );
1157
1164
}
1158
1165
@@ -1163,7 +1170,7 @@ static void calculate_changed_submodule_paths(struct index_state *istate)
1163
1170
initialized_fetch_ref_tips = 0 ;
1164
1171
}
1165
1172
1166
- int submodule_touches_in_range (struct index_state * istate ,
1173
+ int submodule_touches_in_range (struct repository * r ,
1167
1174
struct object_id * excl_oid ,
1168
1175
struct object_id * incl_oid )
1169
1176
{
@@ -1172,7 +1179,7 @@ int submodule_touches_in_range(struct index_state *istate,
1172
1179
int ret ;
1173
1180
1174
1181
/* 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 ))
1176
1183
return 0 ;
1177
1184
1178
1185
argv_array_push (& args , "--" ); /* args[0] program name */
@@ -1182,7 +1189,7 @@ int submodule_touches_in_range(struct index_state *istate,
1182
1189
argv_array_push (& args , oid_to_hex (excl_oid ));
1183
1190
}
1184
1191
1185
- collect_changed_submodules (istate , & subs , & args );
1192
+ collect_changed_submodules (r , & subs , & args );
1186
1193
ret = subs .nr ;
1187
1194
1188
1195
argv_array_clear (& args );
@@ -1352,7 +1359,7 @@ int fetch_populated_submodules(struct repository *r,
1352
1359
argv_array_push (& spf .args , "--recurse-submodules-default" );
1353
1360
/* default value, "--submodule-prefix" and its value are added later */
1354
1361
1355
- calculate_changed_submodule_paths (r -> index );
1362
+ calculate_changed_submodule_paths (r );
1356
1363
run_processes_parallel (max_parallel_jobs ,
1357
1364
get_next_submodule ,
1358
1365
fetch_start_failure ,
0 commit comments