@@ -1389,6 +1389,7 @@ struct fetch_task {
1389
1389
struct repository * repo ;
1390
1390
const struct submodule * sub ;
1391
1391
unsigned free_sub : 1 ; /* Do we need to free the submodule? */
1392
+ const char * default_argv ; /* The default fetch mode. */
1392
1393
1393
1394
struct oid_array * commits ; /* Ensure these commits are fetched */
1394
1395
};
@@ -1466,14 +1467,11 @@ static struct repository *get_submodule_repo_for(struct repository *r,
1466
1467
return ret ;
1467
1468
}
1468
1469
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 )
1471
1472
{
1472
- struct submodule_parallel_fetch * spf = data ;
1473
-
1474
1473
for (; spf -> count < spf -> r -> index -> cache_nr ; spf -> count ++ ) {
1475
1474
const struct cache_entry * ce = spf -> r -> index -> cache [spf -> count ];
1476
- const char * default_argv ;
1477
1475
struct fetch_task * task ;
1478
1476
1479
1477
if (!S_ISGITLINK (ce -> ce_mode ))
@@ -1493,40 +1491,23 @@ static int get_next_submodule(struct child_process *cp,
1493
1491
& spf -> changed_submodule_names ,
1494
1492
task -> sub -> name ))
1495
1493
continue ;
1496
- default_argv = "on-demand" ;
1494
+ task -> default_argv = "on-demand" ;
1497
1495
break ;
1498
1496
case RECURSE_SUBMODULES_ON :
1499
- default_argv = "yes" ;
1497
+ task -> default_argv = "yes" ;
1500
1498
break ;
1501
1499
case RECURSE_SUBMODULES_OFF :
1502
1500
continue ;
1503
1501
}
1504
1502
1505
1503
task -> repo = get_submodule_repo_for (spf -> r , task -> sub -> path , null_oid ());
1506
1504
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 ;
1512
1505
if (!spf -> quiet )
1513
1506
strbuf_addf (err , _ ("Fetching submodule %s%s\n" ),
1514
1507
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 );
1524
1508
1525
1509
spf -> count ++ ;
1526
- * task_cb = task ;
1527
-
1528
- strbuf_release (& submodule_prefix );
1529
- return 1 ;
1510
+ return task ;
1530
1511
} else {
1531
1512
struct strbuf empty_submodule_path = STRBUF_INIT ;
1532
1513
@@ -1550,6 +1531,36 @@ static int get_next_submodule(struct child_process *cp,
1550
1531
strbuf_release (& empty_submodule_path );
1551
1532
}
1552
1533
}
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
+ }
1553
1564
1554
1565
if (spf -> oid_fetch_tasks_nr ) {
1555
1566
struct fetch_task * task =
0 commit comments