@@ -1235,7 +1235,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
1235
1235
1236
1236
static int clone_submodule (const char * path , const char * gitdir , const char * url ,
1237
1237
const char * depth , struct string_list * reference , int dissociate ,
1238
- int quiet , int progress )
1238
+ int quiet , int progress , int single_branch )
1239
1239
{
1240
1240
struct child_process cp = CHILD_PROCESS_INIT ;
1241
1241
@@ -1257,6 +1257,10 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url
1257
1257
argv_array_push (& cp .args , "--dissociate" );
1258
1258
if (gitdir && * gitdir )
1259
1259
argv_array_pushl (& cp .args , "--separate-git-dir" , gitdir , NULL );
1260
+ if (single_branch >= 0 )
1261
+ argv_array_push (& cp .args , single_branch ?
1262
+ "--single-branch" :
1263
+ "--no-single-branch" );
1260
1264
1261
1265
argv_array_push (& cp .args , "--" );
1262
1266
argv_array_push (& cp .args , url );
@@ -1383,6 +1387,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1383
1387
struct string_list reference = STRING_LIST_INIT_NODUP ;
1384
1388
int dissociate = 0 , require_init = 0 ;
1385
1389
char * sm_alternate = NULL , * error_strategy = NULL ;
1390
+ int single_branch = -1 ;
1386
1391
1387
1392
struct option module_clone_options [] = {
1388
1393
OPT_STRING (0 , "prefix" , & prefix ,
@@ -1410,12 +1415,15 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1410
1415
N_ ("force cloning progress" )),
1411
1416
OPT_BOOL (0 , "require-init" , & require_init ,
1412
1417
N_ ("disallow cloning into non-empty directory" )),
1418
+ OPT_BOOL (0 , "single-branch" , & single_branch ,
1419
+ N_ ("clone only one branch, HEAD or --branch" )),
1413
1420
OPT_END ()
1414
1421
};
1415
1422
1416
1423
const char * const git_submodule_helper_usage [] = {
1417
1424
N_ ("git submodule--helper clone [--prefix=<path>] [--quiet] "
1418
1425
"[--reference <repository>] [--name <name>] [--depth <depth>] "
1426
+ "[--single-branch] "
1419
1427
"--url <url> --path <path>" ),
1420
1428
NULL
1421
1429
};
@@ -1448,7 +1456,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1448
1456
prepare_possible_alternates (name , & reference );
1449
1457
1450
1458
if (clone_submodule (path , sm_gitdir , url , depth , & reference , dissociate ,
1451
- quiet , progress ))
1459
+ quiet , progress , single_branch ))
1452
1460
die (_ ("clone of '%s' into submodule path '%s' failed" ),
1453
1461
url , path );
1454
1462
} else {
@@ -1572,6 +1580,7 @@ struct submodule_update_clone {
1572
1580
const char * depth ;
1573
1581
const char * recursive_prefix ;
1574
1582
const char * prefix ;
1583
+ int single_branch ;
1575
1584
1576
1585
/* to be consumed by git-submodule.sh */
1577
1586
struct update_clone_data * update_clone ;
@@ -1586,10 +1595,14 @@ struct submodule_update_clone {
1586
1595
1587
1596
int max_jobs ;
1588
1597
};
1589
- #define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \
1590
- SUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, 0, 0, \
1591
- NULL, NULL, NULL, \
1592
- NULL, 0, 0, 0, NULL, 0, 0, 1}
1598
+ #define SUBMODULE_UPDATE_CLONE_INIT { \
1599
+ .list = MODULE_LIST_INIT, \
1600
+ .update = SUBMODULE_UPDATE_STRATEGY_INIT, \
1601
+ .recommend_shallow = -1, \
1602
+ .references = STRING_LIST_INIT_DUP, \
1603
+ .single_branch = -1, \
1604
+ .max_jobs = 1, \
1605
+ }
1593
1606
1594
1607
1595
1608
static void next_submodule_warn_missing (struct submodule_update_clone * suc ,
@@ -1728,6 +1741,10 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
1728
1741
argv_array_push (& child -> args , "--dissociate" );
1729
1742
if (suc -> depth )
1730
1743
argv_array_push (& child -> args , suc -> depth );
1744
+ if (suc -> single_branch >= 0 )
1745
+ argv_array_push (& child -> args , suc -> single_branch ?
1746
+ "--single-branch" :
1747
+ "--no-single-branch" );
1731
1748
1732
1749
cleanup :
1733
1750
strbuf_reset (& displaypath_sb );
@@ -1907,6 +1924,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
1907
1924
N_ ("force cloning progress" )),
1908
1925
OPT_BOOL (0 , "require-init" , & suc .require_init ,
1909
1926
N_ ("disallow cloning into non-empty directory" )),
1927
+ OPT_BOOL (0 , "single-branch" , & suc .single_branch ,
1928
+ N_ ("clone only one branch, HEAD or --branch" )),
1910
1929
OPT_END ()
1911
1930
};
1912
1931
0 commit comments