@@ -228,24 +228,26 @@ def report_hook(index, blksize, size):
228
228
break
229
229
return target
230
230
elif parsed_url .scheme in ('git' , 'git+file' , 'git+ssh' , 'git+http' , 'git+https' ):
231
- if isdir (target ):
232
- with current_directory (target ):
233
- shprint (sh .git , 'fetch' , '--tags' , '--recurse-submodules' )
234
- if self .version :
235
- shprint (sh .git , 'checkout' , self .version )
236
- branch = sh .git ('branch' , '--show-current' )
237
- if branch :
238
- shprint (sh .git , 'pull' )
239
- shprint (sh .git , 'pull' , '--recurse-submodules' )
240
- shprint (sh .git , 'submodule' , 'update' , '--recursive' )
241
- else :
231
+ if not isdir (target ):
242
232
if url .startswith ('git+' ):
243
233
url = url [4 :]
244
- shprint ( sh . git , 'clone' , '--recursive' , url , target )
234
+ # if 'version' is specified, do a shallow clone
245
235
if self .version :
236
+ shprint (sh .mkdir , '-p' , target )
246
237
with current_directory (target ):
247
- shprint (sh .git , 'checkout' , self .version )
248
- shprint (sh .git , 'submodule' , 'update' , '--recursive' )
238
+ shprint (sh .git , 'init' )
239
+ shprint (sh .git , 'remote' , 'add' , 'origin' , url )
240
+ else :
241
+ shprint (sh .git , 'clone' , '--recursive' , url , target )
242
+ with current_directory (target ):
243
+ if self .version :
244
+ shprint (sh .git , 'fetch' , '--depth' , '1' , 'origin' , self .version )
245
+ shprint (sh .git , 'checkout' , self .version )
246
+ branch = sh .git ('branch' , '--show-current' )
247
+ if branch :
248
+ shprint (sh .git , 'pull' )
249
+ shprint (sh .git , 'pull' , '--recurse-submodules' )
250
+ shprint (sh .git , 'submodule' , 'update' , '--recursive' , '--init' , '--depth' , '1' )
249
251
return target
250
252
251
253
def apply_patch (self , filename , arch , build_dir = None ):
0 commit comments