Skip to content

Commit 1e5dd3a

Browse files
chooglengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c2f8cc commit 1e5dd3a

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

submodule.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -782,19 +782,6 @@ const struct submodule *submodule_from_ce(const struct cache_entry *ce)
782782
return submodule_from_path(the_repository, null_oid(), ce->name);
783783
}
784784

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-
}
798785

799786
struct collect_changed_submodules_cb_data {
800787
struct repository *repo;
@@ -830,9 +817,9 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
830817

831818
for (i = 0; i < q->nr; i++) {
832819
struct diff_filepair *p = q->queue[i];
833-
struct oid_array *commits;
834820
const struct submodule *submodule;
835821
const char *name;
822+
struct string_list_item *item;
836823

837824
if (!S_ISGITLINK(p->two->mode))
838825
continue;
@@ -859,8 +846,11 @@ static void collect_changed_submodules_cb(struct diff_queue_struct *q,
859846
if (!name)
860847
continue;
861848

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);
864854
}
865855
}
866856

0 commit comments

Comments
 (0)