diff options
-rw-r--r-- | source_control/git.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source_control/git.py b/source_control/git.py index c3b74057..55bed66e 100644 --- a/source_control/git.py +++ b/source_control/git.py @@ -380,12 +380,17 @@ def clone(git_path, module, repo, dest, remote, depth, version, bare, else: cmd.extend([ '--origin', remote ]) if depth: - if version == 'HEAD' \ - or refspec \ - or is_remote_branch(git_path, module, dest, repo, version) \ - or is_remote_tag(git_path, module, dest, repo, version): - # only use depth if the remote opject is branch or tag (i.e. fetchable) + if version == 'HEAD' or refspec: + cmd.extend([ '--depth', str(depth) ]) + elif is_remote_branch(git_path, module, dest, repo, version) \ + or is_remote_tag(git_path, module, dest, repo, version): cmd.extend([ '--depth', str(depth) ]) + cmd.extend([ '--branch', version ]) + else: + # only use depth if the remote opject is branch or tag (i.e. fetchable) + module.warn("Ignoring depth argument. " + "Shallow clones are only available for " + "HEAD, branches, tags or in combination with refspec.") if reference: cmd.extend([ '--reference', str(reference) ]) cmd.extend([ repo, dest ]) |