@@ -932,6 +932,7 @@ struct has_commit_data {
932932 struct repository * repo ;
933933 int result ;
934934 const char * path ;
935+ const struct object_id * super_oid ;
935936};
936937
937938static int check_has_commit (const struct object_id * oid , void * data )
@@ -940,7 +941,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
940941 struct repository subrepo ;
941942 enum object_type type ;
942943
943- if (repo_submodule_init (& subrepo , cb -> repo , cb -> path , null_oid () )) {
944+ if (repo_submodule_init (& subrepo , cb -> repo , cb -> path , cb -> super_oid )) {
944945 cb -> result = 0 ;
945946 goto cleanup ;
946947 }
@@ -968,9 +969,15 @@ static int check_has_commit(const struct object_id *oid, void *data)
968969
969970static int submodule_has_commits (struct repository * r ,
970971 const char * path ,
972+ const struct object_id * super_oid ,
971973 struct oid_array * commits )
972974{
973- struct has_commit_data has_commit = { r , 1 , path };
975+ struct has_commit_data has_commit = {
976+ .repo = r ,
977+ .result = 1 ,
978+ .path = path ,
979+ .super_oid = super_oid
980+ };
974981
975982 /*
976983 * Perform a cheap, but incorrect check for the existence of 'commits'.
@@ -1017,7 +1024,7 @@ static int submodule_needs_pushing(struct repository *r,
10171024 const char * path ,
10181025 struct oid_array * commits )
10191026{
1020- if (!submodule_has_commits (r , path , commits ))
1027+ if (!submodule_has_commits (r , path , null_oid (), commits ))
10211028 /*
10221029 * NOTE: We do consider it safe to return "no" here. The
10231030 * correct answer would be "We do not know" instead of
@@ -1277,7 +1284,7 @@ static void calculate_changed_submodule_paths(struct repository *r,
12771284 if (!path )
12781285 continue ;
12791286
1280- if (submodule_has_commits (r , path , commits )) {
1287+ if (submodule_has_commits (r , path , null_oid (), commits )) {
12811288 oid_array_clear (commits );
12821289 * name -> string = '\0' ;
12831290 }
@@ -1402,12 +1409,13 @@ static const struct submodule *get_non_gitmodules_submodule(const char *path)
14021409}
14031410
14041411static struct fetch_task * fetch_task_create (struct repository * r ,
1405- const char * path )
1412+ const char * path ,
1413+ const struct object_id * treeish_name )
14061414{
14071415 struct fetch_task * task = xmalloc (sizeof (* task ));
14081416 memset (task , 0 , sizeof (* task ));
14091417
1410- task -> sub = submodule_from_path (r , null_oid () , path );
1418+ task -> sub = submodule_from_path (r , treeish_name , path );
14111419 if (!task -> sub ) {
14121420 /*
14131421 * No entry in .gitmodules? Technically not a submodule,
@@ -1439,11 +1447,12 @@ static void fetch_task_release(struct fetch_task *p)
14391447}
14401448
14411449static struct repository * get_submodule_repo_for (struct repository * r ,
1442- const char * path )
1450+ const char * path ,
1451+ const struct object_id * treeish_name )
14431452{
14441453 struct repository * ret = xmalloc (sizeof (* ret ));
14451454
1446- if (repo_submodule_init (ret , r , path , null_oid () )) {
1455+ if (repo_submodule_init (ret , r , path , treeish_name )) {
14471456 free (ret );
14481457 return NULL ;
14491458 }
@@ -1464,7 +1473,7 @@ static int get_next_submodule(struct child_process *cp,
14641473 if (!S_ISGITLINK (ce -> ce_mode ))
14651474 continue ;
14661475
1467- task = fetch_task_create (spf -> r , ce -> name );
1476+ task = fetch_task_create (spf -> r , ce -> name , null_oid () );
14681477 if (!task )
14691478 continue ;
14701479
@@ -1487,7 +1496,7 @@ static int get_next_submodule(struct child_process *cp,
14871496 continue ;
14881497 }
14891498
1490- task -> repo = get_submodule_repo_for (spf -> r , task -> sub -> path );
1499+ task -> repo = get_submodule_repo_for (spf -> r , task -> sub -> path , null_oid () );
14911500 if (task -> repo ) {
14921501 struct strbuf submodule_prefix = STRBUF_INIT ;
14931502 child_process_init (cp );
0 commit comments