@@ -739,7 +739,7 @@ class GitCacheError(Exception):
739739class MirroredGitRepo (object ):
740740
741741 def __init__ (self , repo_url , repos_dir , locks_dir , timeout = 60 ,
742- logger = None ):
742+ git_command_extras = None , logger = None ):
743743 """
744744 @type repo_url: str or unicode
745745 @param repo_url: Git repository URL.
@@ -750,6 +750,8 @@ def __init__(self, repo_url, repos_dir, locks_dir, timeout=60,
750750 need the timeout.
751751 @type logger: logging.Logger
752752 @param logger: Logger instance to use (optional).
753+ @type git_command_extras: list of str
754+ @param git_command_extras: List of extra command line options to be passed to git (optional)
753755 """
754756 if not isinstance (repo_url , str ):
755757 raise ValueError ("repo_url must be instance of str or unicode" )
@@ -782,6 +784,8 @@ def __init__(self, repo_url, repos_dir, locks_dir, timeout=60,
782784 "{0}.lock" .format (self .__repo_hash ))
783785 self .__fd = None
784786
787+ self .__git_command_extras = git_command_extras
788+
785789 def clone_to (self , target_dir , branch = None ):
786790 """
787791 Clones cached git repository to the specified directory.
@@ -839,7 +843,7 @@ def __enter__(self):
839843 raise e
840844 return self
841845
842- def __clone_repo (self , repo_url , target_dir , mirror = False , branch = None ):
846+ def __clone_repo (self , repo_url , target_dir , mirror = False , branch = None , git_opts = None ):
843847 """
844848 Clones git repository to the specified directory.
845849
@@ -849,10 +853,16 @@ def __clone_repo(self, repo_url, target_dir, mirror=False, branch=None):
849853 @param target_dir: The name of a new directory to clone into.
850854 @type mirror: bool
851855 @param mirror: Set up a mirror of the source repository if True.
856+ @type git_opts: list of str
857+ @param git_opts: list of explicit options to append to git command (optional)
852858
853859 @raise GitCacheError: If git-clone execution failed.
854860 """
855861 cmd = ["git" , "clone" ]
862+ if self .__git_command_extras is not None :
863+ cmd .extend ( self .__git_command_extras )
864+ if git_opts is not None :
865+ cmd .extend ( git_opts )
856866 if mirror :
857867 cmd .append ("--mirror" )
858868 cmd .extend ((repo_url , target_dir ))
0 commit comments