Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6e1dcc

Browse filesBrowse files
committed
allow setting depth when cloning a submodule
Signed-off-by: Liam Beguin <liambeguin@gmail.com>
1 parent 09a96fb commit d6e1dcc
Copy full SHA for d6e1dcc

1 file changed

+9-1Lines changed: 9 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/objects/submodule/base.py‎

Copy file name to clipboardExpand all lines: git/objects/submodule/base.py
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.