submodule: inline submodule_commits() into caller
When collecting the string_list of changed submodule names, the new submodules commits are stored in the string_list_item.util as an oid_array. A subsequent commit will replace the oid_array with a struct that has more information. Prepare for this change by inlining submodule_commits() (which inserts into the string_list and initializes the string_list_item.util) into its only caller so that the code is easier to refactor later. Signed-off-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Glen Choo committed
Mar 7, 2022 at 16:14 UTC
1e5dd3a1114643ca43e3d83da4f5c44447f061ff
1 file changed
+6
-16
submodule.c
+6
-16
@@ -782,19 +782,6 @@ const struct submodule *submodule_from_ce(const struct cache_entry *ce)
782
return submodule_from_path(the_repository, null_oid(), ce->name);
783
}
784
785
-static struct oid_array *submodule_commits(struct string_list *submodules,
786
- const char *name)
787
-{
788
- struct string_list_item *item;
789
-
790
- item = string_list_insert(submodules, name);
791
- if (item->util)
792
- return (struct oid_array *) item->util;
793
-
794
- /* NEEDSWORK: should we have oid_array_init()? */
795
- item->util = xcalloc(1, sizeof(struct oid_array));
796
- return (struct oid_array *) item->util;
797
-}
785
786
struct collect_changed_submodules_cb_data {
787
struct repository *repo;
@@ -830,9 +817,9 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
817
818
for (i = 0; i < q->nr; i++) {
819
struct diff_filepair *p = q->queue[i];
833
- struct oid_array *commits;
820
const struct submodule *submodule;
821
const char *name;
822
+ struct string_list_item *item;
823
824
if (!S_ISGITLINK(p->two->mode))
825
continue;
@@ -859,8 +846,11 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
846
if (!name)
847
continue;
848
862
- commits = submodule_commits(changed, name);
863
- oid_array_append(commits, &p->two->oid);
849
+ item = string_list_insert(changed, name);
850
+ 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);
854
}
855
}
856