@@ -806,6 +806,20 @@ static const char *default_name_or_path(const char *path_or_name)
806
806
return path_or_name ;
807
807
}
808
808
809
+ /*
810
+ * Holds relevant information for a changed submodule. Used as the .util
811
+ * member of the changed submodule string_list_item.
812
+ */
813
+ struct changed_submodule_data {
814
+ /* The submodule commits that have changed in the rev walk. */
815
+ struct oid_array new_commits ;
816
+ };
817
+
818
+ static void changed_submodule_data_clear (struct changed_submodule_data * cs_data )
819
+ {
820
+ oid_array_clear (& cs_data -> new_commits );
821
+ }
822
+
809
823
static void collect_changed_submodules_cb (struct diff_queue_struct * q ,
810
824
struct diff_options * options ,
811
825
void * data )
@@ -820,6 +834,7 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
820
834
const struct submodule * submodule ;
821
835
const char * name ;
822
836
struct string_list_item * item ;
837
+ struct changed_submodule_data * cs_data ;
823
838
824
839
if (!S_ISGITLINK (p -> two -> mode ))
825
840
continue ;
@@ -848,9 +863,9 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
848
863
849
864
item = string_list_insert (changed , name );
850
865
if (!item -> util )
851
- /* NEEDSWORK: should we have oid_array_init()? */
852
- item -> util = xcalloc ( 1 , sizeof ( struct oid_array )) ;
853
- oid_array_append (item -> util , & p -> two -> oid );
866
+ item -> util = xcalloc ( 1 , sizeof ( struct changed_submodule_data ));
867
+ cs_data = item -> util ;
868
+ oid_array_append (& cs_data -> new_commits , & p -> two -> oid );
854
869
}
855
870
}
856
871
@@ -897,11 +912,12 @@ static void collect_changed_submodules(struct repository *r,
897
912
reset_revision_walk ();
898
913
}
899
914
900
- static void free_submodules_oids (struct string_list * submodules )
915
+ static void free_submodules_data (struct string_list * submodules )
901
916
{
902
917
struct string_list_item * item ;
903
918
for_each_string_list_item (item , submodules )
904
- oid_array_clear ((struct oid_array * ) item -> util );
919
+ changed_submodule_data_clear (item -> util );
920
+
905
921
string_list_clear (submodules , 1 );
906
922
}
907
923
@@ -1074,7 +1090,7 @@ int find_unpushed_submodules(struct repository *r,
1074
1090
collect_changed_submodules (r , & submodules , & argv );
1075
1091
1076
1092
for_each_string_list_item (name , & submodules ) {
1077
- struct oid_array * commits = name -> util ;
1093
+ struct changed_submodule_data * cs_data = name -> util ;
1078
1094
const struct submodule * submodule ;
1079
1095
const char * path = NULL ;
1080
1096
@@ -1087,11 +1103,11 @@ int find_unpushed_submodules(struct repository *r,
1087
1103
if (!path )
1088
1104
continue ;
1089
1105
1090
- if (submodule_needs_pushing (r , path , commits ))
1106
+ if (submodule_needs_pushing (r , path , & cs_data -> new_commits ))
1091
1107
string_list_insert (needs_pushing , path );
1092
1108
}
1093
1109
1094
- free_submodules_oids (& submodules );
1110
+ free_submodules_data (& submodules );
1095
1111
strvec_clear (& argv );
1096
1112
1097
1113
return needs_pushing -> nr ;
@@ -1261,7 +1277,7 @@ static void calculate_changed_submodule_paths(struct repository *r,
1261
1277
collect_changed_submodules (r , changed_submodule_names , & argv );
1262
1278
1263
1279
for_each_string_list_item (name , changed_submodule_names ) {
1264
- struct oid_array * commits = name -> util ;
1280
+ struct changed_submodule_data * cs_data = name -> util ;
1265
1281
const struct submodule * submodule ;
1266
1282
const char * path = NULL ;
1267
1283
@@ -1274,8 +1290,8 @@ static void calculate_changed_submodule_paths(struct repository *r,
1274
1290
if (!path )
1275
1291
continue ;
1276
1292
1277
- if (submodule_has_commits (r , path , null_oid (), commits )) {
1278
- oid_array_clear ( commits );
1293
+ if (submodule_has_commits (r , path , null_oid (), & cs_data -> new_commits )) {
1294
+ changed_submodule_data_clear ( cs_data );
1279
1295
* name -> string = '\0' ;
1280
1296
}
1281
1297
}
@@ -1312,7 +1328,7 @@ int submodule_touches_in_range(struct repository *r,
1312
1328
1313
1329
strvec_clear (& args );
1314
1330
1315
- free_submodules_oids (& subs );
1331
+ free_submodules_data (& subs );
1316
1332
return ret ;
1317
1333
}
1318
1334
@@ -1596,7 +1612,7 @@ static int fetch_finish(int retvalue, struct strbuf *err,
1596
1612
struct fetch_task * task = task_cb ;
1597
1613
1598
1614
struct string_list_item * it ;
1599
- struct oid_array * commits ;
1615
+ struct changed_submodule_data * cs_data ;
1600
1616
1601
1617
if (!task || !task -> sub )
1602
1618
BUG ("callback cookie bogus" );
@@ -1624,14 +1640,14 @@ static int fetch_finish(int retvalue, struct strbuf *err,
1624
1640
/* Could be an unchanged submodule, not contained in the list */
1625
1641
goto out ;
1626
1642
1627
- commits = it -> util ;
1628
- oid_array_filter (commits ,
1643
+ cs_data = it -> util ;
1644
+ oid_array_filter (& cs_data -> new_commits ,
1629
1645
commit_missing_in_sub ,
1630
1646
task -> repo );
1631
1647
1632
1648
/* Are there commits we want, but do not exist? */
1633
- if (commits -> nr ) {
1634
- task -> commits = commits ;
1649
+ if (cs_data -> new_commits . nr ) {
1650
+ task -> commits = & cs_data -> new_commits ;
1635
1651
ALLOC_GROW (spf -> oid_fetch_tasks ,
1636
1652
spf -> oid_fetch_tasks_nr + 1 ,
1637
1653
spf -> oid_fetch_tasks_alloc );
@@ -1689,7 +1705,7 @@ int fetch_populated_submodules(struct repository *r,
1689
1705
1690
1706
strvec_clear (& spf .args );
1691
1707
out :
1692
- free_submodules_oids (& spf .changed_submodule_names );
1708
+ free_submodules_data (& spf .changed_submodule_names );
1693
1709
return spf .result ;
1694
1710
}
1695
1711
0 commit comments