diff --git a/pythonforandroid/recipe.py b/pythonforandroid/recipe.py index b4cd9bb3cf..130db7a559 100644 --- a/pythonforandroid/recipe.py +++ b/pythonforandroid/recipe.py @@ -213,24 +213,26 @@ def report_hook(index, blksize, size): break return target elif parsed_url.scheme in ('git', 'git+file', 'git+ssh', 'git+http', 'git+https'): - if isdir(target): - with current_directory(target): - shprint(sh.git, 'fetch', '--tags', '--recurse-submodules') - if self.version: - shprint(sh.git, 'checkout', self.version) - branch = sh.git('branch', '--show-current') - if branch: - shprint(sh.git, 'pull') - shprint(sh.git, 'pull', '--recurse-submodules') - shprint(sh.git, 'submodule', 'update', '--recursive') - else: + if not isdir(target): if url.startswith('git+'): url = url[4:] - shprint(sh.git, 'clone', '--recursive', url, target) + # if 'version' is specified, do a shallow clone if self.version: + shprint(sh.mkdir, '-p', target) with current_directory(target): - shprint(sh.git, 'checkout', self.version) - shprint(sh.git, 'submodule', 'update', '--recursive') + shprint(sh.git, 'init') + shprint(sh.git, 'remote', 'add', 'origin', url) + else: + shprint(sh.git, 'clone', '--recursive', url, target) + with current_directory(target): + if self.version: + shprint(sh.git, 'fetch', '--depth', '1', 'origin', self.version) + shprint(sh.git, 'checkout', self.version) + branch = sh.git('branch', '--show-current') + if branch: + shprint(sh.git, 'pull') + shprint(sh.git, 'pull', '--recurse-submodules') + shprint(sh.git, 'submodule', 'update', '--recursive', '--init', '--depth', '1') return target def apply_patch(self, filename, arch, build_dir=None):