@@ -309,7 +309,7 @@ def _write_git_file_and_module_config(cls, working_tree_dir, module_abspath):
309309 #{ Edit Interface
310310
311311 @classmethod
312- def add (cls , repo , name , path , url = None , branch = None , no_checkout = False ):
312+ def add (cls , repo , name , path , url = None , branch = None , no_checkout = False , depth = None ):
313313 """Add a new submodule to the given repository. This will alter the index
314314 as well as the .gitmodules file, but will not create a new commit.
315315 If the submodule already exists, no matter if the configuration differs
@@ -334,6 +334,8 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
334334 Examples are 'master' or 'feature/new'
335335 :param no_checkout: if True, and if the repository has to be cloned manually,
336336 no checkout will be performed
337+ :param depth: Create a shallow clone with a history truncated to the
338+ specified number of commits.
337339 :return: The newly created submodule instance
338340 :note: works atomically, such that no change will be done if the repository
339341 update fails for instance"""
@@ -395,6 +397,12 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
395397 kwargs ['b' ] = br .name
396398 # END setup checkout-branch
397399
400+ if depth :
401+ if isinstance (depth , int ):
402+ kwargs ['depth' ] = depth
403+ else :
404+ raise ValueError ("depth should be an integer" )
405+
398406 # _clone_repo(cls, repo, url, path, name, **kwargs):
399407 mrepo = cls ._clone_repo (repo , url , path , name , ** kwargs )
400408 # END verify url
0 commit comments