@@ -2591,6 +2591,8 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
25912591 recursive = git_config .pop ('recursive' , False )
25922592 clone_into = git_config .pop ('clone_into' , False )
25932593 keep_git_dir = git_config .pop ('keep_git_dir' , False )
2594+ extra_config_params = git_config .pop ('extra_config_params' , None )
2595+ recurse_submodules = git_config .pop ('recurse_submodules' , None )
25942596
25952597 # input validation of git_config dict
25962598 if git_config :
@@ -2616,7 +2618,11 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
26162618 targetpath = os .path .join (targetdir , filename )
26172619
26182620 # compose 'git clone' command, and run it
2619- clone_cmd = ['git' , 'clone' ]
2621+ if extra_config_params :
2622+ git_cmd = 'git ' + ' ' .join (['-c %s' % param for param in extra_config_params ])
2623+ else :
2624+ git_cmd = 'git'
2625+ clone_cmd = [git_cmd , 'clone' ]
26202626
26212627 if not keep_git_dir and not commit :
26222628 # Speed up cloning by only fetching the most recent commit, not the whole history
@@ -2627,6 +2633,8 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
26272633 clone_cmd .extend (['--branch' , tag ])
26282634 if recursive :
26292635 clone_cmd .append ('--recursive' )
2636+ if recurse_submodules :
2637+ clone_cmd .extend (["--recurse-submodules='%s'" % pat for pat in recurse_submodules ])
26302638 else :
26312639 # checkout is done separately below for specific commits
26322640 clone_cmd .append ('--no-checkout' )
@@ -2646,17 +2654,22 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
26462654
26472655 # if a specific commit is asked for, check it out
26482656 if commit :
2649- checkout_cmd = ['git' , 'checkout' , commit ]
2650- if recursive :
2651- checkout_cmd .extend (['&&' , 'git' , 'submodule' , 'update' , '--init' , '--recursive' ])
2657+ checkout_cmd = [git_cmd , 'checkout' , commit ]
2658+
2659+ if recursive or recurse_submodules :
2660+ checkout_cmd .extend (['&&' , git_cmd , 'submodule' , 'update' , '--init' ])
2661+ if recursive :
2662+ checkout_cmd .append ('--recursive' )
2663+ if recurse_submodules :
2664+ checkout_cmd .extend (["--recurse-submodules='%s'" % pat for pat in recurse_submodules ])
26522665
26532666 work_dir = os .path .join (tmpdir , repo_name ) if repo_name else tmpdir
26542667 run_shell_cmd (' ' .join (checkout_cmd ), work_dir = work_dir , hidden = True , verbose_dry_run = True )
26552668
26562669 elif not build_option ('extended_dry_run' ):
26572670 # If we wanted to get a tag make sure we actually got a tag and not a branch with the same name
26582671 # This doesn't make sense in dry-run mode as we don't have anything to check
2659- cmd = "git describe --exact-match --tags HEAD"
2672+ cmd = f" { git_cmd } describe --exact-match --tags HEAD"
26602673 work_dir = os .path .join (tmpdir , repo_name ) if repo_name else tmpdir
26612674 res = run_shell_cmd (cmd , fail_on_error = False , work_dir = work_dir , hidden = True , verbose_dry_run = True )
26622675
@@ -2671,13 +2684,17 @@ def get_source_tarball_from_git(filename, targetdir, git_config):
26712684 # make the repo unshallow first;
26722685 # this is equivalent with 'git fetch -unshallow' in Git 1.8.3+
26732686 # (first fetch seems to do nothing, unclear why)
2674- cmds .append ("git fetch --depth=2147483647 && git fetch --depth=2147483647" )
2687+ cmds .append (f" { git_cmd } fetch --depth=2147483647 && git fetch --depth=2147483647" )
26752688
2676- cmds .append (f"git checkout refs/tags/{ tag } " )
2689+ cmds .append (f"{ git_cmd } checkout refs/tags/{ tag } " )
26772690 # Clean all untracked files, e.g. from left-over submodules
2678- cmds .append ("git clean --force -d -x" )
2691+ cmds .append (f" { git_cmd } clean --force -d -x" )
26792692 if recursive :
2680- cmds .append ("git submodule update --init --recursive" )
2693+ cmds .append (f"{ git_cmd } submodule update --init --recursive" )
2694+ elif recurse_submodules :
2695+ cmds .append (f"{ git_cmd } submodule update --init " )
2696+ cmds [- 1 ] += ' ' .join (["--recurse-submodules='%s'" % pat for pat in recurse_submodules ])
2697+
26812698 for cmd in cmds :
26822699 run_shell_cmd (cmd , work_dir = work_dir , hidden = True , verbose_dry_run = True )
26832700
0 commit comments