@@ -263,23 +263,21 @@ def clone_repositories(checkout_path: str, tc_version: LLVMBMTC,
263263 logging .info (' - %s: %s @ %s%s' , repo_path , module .branch ,
264264 module .revision ,
265265 ' (detached)' if module .revision != 'HEAD' else '' )
266+ refspec = (module .branch if module .revision == 'HEAD'
267+ else module .revision )
268+
266269 repo = git .Repo .clone_from (module .url ,
267- os .path .join (checkout_path , module .name ))
268- if module .revision == 'HEAD' :
269- try :
270- repo .git .checkout (module .branch )
271- except git .exc .GitCommandError as ex : # pylint: disable=no-member
272- die ('could not checkout "{}" @ "{}/{}"\n '
273- 'Git command failed with:\n {}'
274- .format (repo_path , module .branch , module .revision , ex ))
275- else :
276- # Detached state
277- try :
278- repo .git .checkout (module .revision )
279- except git .exc .GitCommandError as ex : # pylint: disable=no-member
280- die ('could not checkout "{}" @ "{}".\n '
281- 'Git command failed with:\n {}'
282- .format (repo_path , module .revision , ex ))
270+ os .path .join (checkout_path , module .name ),
271+ multi_options = [
272+ "--branch %s" % (refspec ),
273+ "--depth 1"
274+ ])
275+ try :
276+ repo .git .checkout (module .revision )
277+ except git .exc .GitCommandError as ex : # pylint: disable=no-member
278+ die ('could not checkout "{}" @ "{}".\n '
279+ 'Git command failed with:\n {}'
280+ .format (repo_path , refspec , ex ))
283281
284282 patch_repositories (checkout_path , tc_version , patches )
285283
0 commit comments