@@ -335,7 +335,7 @@ def _write_git_file_and_module_config(cls, working_tree_dir, module_abspath):
335
335
336
336
@classmethod
337
337
def add (cls , repo : 'Repo' , name : str , path : PathLike , url : Union [str , None ] = None ,
338
- branch = None , no_checkout : bool = False , depth = None , env = None
338
+ branch = None , no_checkout : bool = False , depth = None , env = None , clone_multi_options = None
339
339
) -> 'Submodule' :
340
340
"""Add a new submodule to the given repository. This will alter the index
341
341
as well as the .gitmodules file, but will not create a new commit.
@@ -369,6 +369,8 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
369
369
and is defined in `os.environ`, value from `os.environ` will be used.
370
370
If you want to unset some variable, consider providing empty string
371
371
as its value.
372
+ :param clone_multi_options: A list of Clone options. Please see ``git.repo.base.Repo.clone``
373
+ for details.
372
374
:return: The newly created submodule instance
373
375
:note: works atomically, such that no change will be done if the repository
374
376
update fails for instance"""
@@ -381,15 +383,15 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
381
383
# assure we never put backslashes into the url, as some operating systems
382
384
# like it ...
383
385
if url is not None :
384
- url = to_native_path_linux (url ) # to_native_path_linux does nothing??
386
+ url = to_native_path_linux (url )
385
387
# END assure url correctness
386
388
387
389
# INSTANTIATE INTERMEDIATE SM
388
390
sm = cls (repo , cls .NULL_BIN_SHA , cls .k_default_mode , path , name , url = 'invalid-temporary' )
389
391
if sm .exists ():
390
392
# reretrieve submodule from tree
391
393
try :
392
- sm = repo .head .commit .tree [path ] # type: ignore
394
+ sm = repo .head .commit .tree [path ]
393
395
sm ._name = name
394
396
return sm
395
397
except KeyError :
@@ -435,6 +437,8 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
435
437
kwargs ['depth' ] = depth
436
438
else :
437
439
raise ValueError ("depth should be an integer" )
440
+ if clone_multi_options :
441
+ kwargs ['multi_options' ] = clone_multi_options
438
442
439
443
# _clone_repo(cls, repo, url, path, name, **kwargs):
440
444
mrepo = cls ._clone_repo (repo , url , path , name , env = env , ** kwargs )
@@ -469,7 +473,7 @@ def add(cls, repo: 'Repo', name: str, path: PathLike, url: Union[str, None] = No
469
473
return sm
470
474
471
475
def update (self , recursive = False , init = True , to_latest_revision = False , progress = None , dry_run = False ,
472
- force = False , keep_going = False , env = None ):
476
+ force = False , keep_going = False , env = None , clone_multi_options = None ):
473
477
"""Update the repository of this submodule to point to the checkout
474
478
we point at with the binsha of this instance.
475
479
@@ -500,6 +504,8 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
500
504
and is defined in `os.environ`, value from `os.environ` will be used.
501
505
If you want to unset some variable, consider providing empty string
502
506
as its value.
507
+ :param clone_multi_options: list of Clone options. Please see ``git.repo.base.Repo.clone``
508
+ for details. Only take effect with `init` option.
503
509
:note: does nothing in bare repositories
504
510
:note: method is definitely not atomic if recurisve is True
505
511
:return: self"""
@@ -566,7 +572,8 @@ def update(self, recursive=False, init=True, to_latest_revision=False, progress=
566
572
progress .update (BEGIN | CLONE , 0 , 1 , prefix + "Cloning url '%s' to '%s' in submodule %r" %
567
573
(self .url , checkout_module_abspath , self .name ))
568
574
if not dry_run :
569
- mrepo = self ._clone_repo (self .repo , self .url , self .path , self .name , n = True , env = env )
575
+ mrepo = self ._clone_repo (self .repo , self .url , self .path , self .name , n = True , env = env ,
576
+ multi_options = clone_multi_options )
570
577
# END handle dry-run
571
578
progress .update (END | CLONE , 0 , 1 , prefix + "Done cloning to %s" % checkout_module_abspath )
572
579
@@ -993,7 +1000,7 @@ def set_parent_commit(self, commit: Union[Commit_ish, None], check=True):
993
1000
# If check is False, we might see a parent-commit that doesn't even contain the submodule anymore.
994
1001
# in that case, mark our sha as being NULL
995
1002
try :
996
- self .binsha = pctree [self .path ].binsha # type: ignore
1003
+ self .binsha = pctree [str ( self .path ) ].binsha
997
1004
except KeyError :
998
1005
self .binsha = self .NULL_BIN_SHA
999
1006
# end
0 commit comments