@@ -1389,6 +1389,7 @@ struct fetch_task {
13891389 struct repository * repo ;
13901390 const struct submodule * sub ;
13911391 unsigned free_sub : 1 ; /* Do we need to free the submodule? */
1392+ const char * default_argv ; /* The default fetch mode. */
13921393
13931394 struct oid_array * commits ; /* Ensure these commits are fetched */
13941395};
@@ -1466,14 +1467,11 @@ static struct repository *get_submodule_repo_for(struct repository *r,
14661467 return ret ;
14671468}
14681469
1469- static int get_next_submodule ( struct child_process * cp ,
1470- struct strbuf * err , void * data , void * * task_cb )
1470+ static struct fetch_task *
1471+ get_fetch_task ( struct submodule_parallel_fetch * spf , struct strbuf * err )
14711472{
1472- struct submodule_parallel_fetch * spf = data ;
1473-
14741473 for (; spf -> count < spf -> r -> index -> cache_nr ; spf -> count ++ ) {
14751474 const struct cache_entry * ce = spf -> r -> index -> cache [spf -> count ];
1476- const char * default_argv ;
14771475 struct fetch_task * task ;
14781476
14791477 if (!S_ISGITLINK (ce -> ce_mode ))
@@ -1493,40 +1491,23 @@ static int get_next_submodule(struct child_process *cp,
14931491 & spf -> changed_submodule_names ,
14941492 task -> sub -> name ))
14951493 continue ;
1496- default_argv = "on-demand" ;
1494+ task -> default_argv = "on-demand" ;
14971495 break ;
14981496 case RECURSE_SUBMODULES_ON :
1499- default_argv = "yes" ;
1497+ task -> default_argv = "yes" ;
15001498 break ;
15011499 case RECURSE_SUBMODULES_OFF :
15021500 continue ;
15031501 }
15041502
15051503 task -> repo = get_submodule_repo_for (spf -> r , task -> sub -> path , null_oid ());
15061504 if (task -> repo ) {
1507- struct strbuf submodule_prefix = STRBUF_INIT ;
1508- child_process_init (cp );
1509- cp -> dir = task -> repo -> gitdir ;
1510- prepare_submodule_repo_env_in_gitdir (& cp -> env_array );
1511- cp -> git_cmd = 1 ;
15121505 if (!spf -> quiet )
15131506 strbuf_addf (err , _ ("Fetching submodule %s%s\n" ),
15141507 spf -> prefix , ce -> name );
1515- strvec_init (& cp -> args );
1516- strvec_pushv (& cp -> args , spf -> args .v );
1517- strvec_push (& cp -> args , default_argv );
1518- strvec_push (& cp -> args , "--submodule-prefix" );
1519-
1520- strbuf_addf (& submodule_prefix , "%s%s/" ,
1521- spf -> prefix ,
1522- task -> sub -> path );
1523- strvec_push (& cp -> args , submodule_prefix .buf );
15241508
15251509 spf -> count ++ ;
1526- * task_cb = task ;
1527-
1528- strbuf_release (& submodule_prefix );
1529- return 1 ;
1510+ return task ;
15301511 } else {
15311512 struct strbuf empty_submodule_path = STRBUF_INIT ;
15321513
@@ -1550,6 +1531,36 @@ static int get_next_submodule(struct child_process *cp,
15501531 strbuf_release (& empty_submodule_path );
15511532 }
15521533 }
1534+ return NULL ;
1535+ }
1536+
1537+ static int get_next_submodule (struct child_process * cp , struct strbuf * err ,
1538+ void * data , void * * task_cb )
1539+ {
1540+ struct submodule_parallel_fetch * spf = data ;
1541+ struct fetch_task * task = get_fetch_task (spf , err );
1542+
1543+ if (task ) {
1544+ struct strbuf submodule_prefix = STRBUF_INIT ;
1545+
1546+ child_process_init (cp );
1547+ cp -> dir = task -> repo -> gitdir ;
1548+ prepare_submodule_repo_env_in_gitdir (& cp -> env_array );
1549+ cp -> git_cmd = 1 ;
1550+ strvec_init (& cp -> args );
1551+ strvec_pushv (& cp -> args , spf -> args .v );
1552+ strvec_push (& cp -> args , task -> default_argv );
1553+ strvec_push (& cp -> args , "--submodule-prefix" );
1554+
1555+ strbuf_addf (& submodule_prefix , "%s%s/" ,
1556+ spf -> prefix ,
1557+ task -> sub -> path );
1558+ strvec_push (& cp -> args , submodule_prefix .buf );
1559+ * task_cb = task ;
1560+
1561+ strbuf_release (& submodule_prefix );
1562+ return 1 ;
1563+ }
15531564
15541565 if (spf -> oid_fetch_tasks_nr ) {
15551566 struct fetch_task * task =
0 commit comments