22import argparse
33import contextlib
44import datetime
5+ import distutils .version
56import hashlib
67import os
78import re
@@ -331,6 +332,7 @@ def __init__(self):
331332 self .use_locked_deps = ''
332333 self .use_vendored_sources = ''
333334 self .verbose = False
335+ self .git_version = None
334336
335337 def download_stage0 (self ):
336338 """Fetch the build system for Rust, written in Rust
@@ -743,15 +745,13 @@ def update_submodule(self, module, checked_out, recorded_submodules):
743745
744746 run (["git" , "submodule" , "-q" , "sync" , module ],
745747 cwd = self .rust_root , verbose = self .verbose )
746- try :
747- run (["git" , "submodule" , "update" ,
748- "--init" , "--recursive" , "--progress" , module ],
749- cwd = self .rust_root , verbose = self .verbose , exception = True )
750- except RuntimeError :
751- # Some versions of git don't support --progress.
752- run (["git" , "submodule" , "update" ,
753- "--init" , "--recursive" , module ],
754- cwd = self .rust_root , verbose = self .verbose )
748+
749+ update_args = ["git" , "submodule" , "update" , "--init" , "--recursive" ]
750+ if self .git_version >= distutils .version .LooseVersion ("2.11.0" ):
751+ update_args .append ("--progress" )
752+ update_args .append (module )
753+ run (update_args , cwd = self .rust_root , verbose = self .verbose , exception = True )
754+
755755 run (["git" , "reset" , "-q" , "--hard" ],
756756 cwd = module_path , verbose = self .verbose )
757757 run (["git" , "clean" , "-qdfx" ],
@@ -763,9 +763,13 @@ def update_submodules(self):
763763 self .get_toml ('submodules' ) == "false" :
764764 return
765765
766- # check the existence of 'git' command
766+ default_encoding = sys .getdefaultencoding ()
767+
768+ # check the existence and version of 'git' command
767769 try :
768- subprocess .check_output (['git' , '--version' ])
770+ git_version_output = subprocess .check_output (['git' , '--version' ])
771+ git_version_str = git_version_output .strip ().split ()[2 ].decode (default_encoding )
772+ self .git_version = distutils .version .LooseVersion (git_version_str )
769773 except (subprocess .CalledProcessError , OSError ):
770774 print ("error: `git` is not found, please make sure it's installed and in the path." )
771775 sys .exit (1 )
0 commit comments