6262import os
6363import sys
6464import re
65+ import logging
6566from collections import namedtuple
6667
68+ log = logging .getLogger (__name__ )
69+
6770DefaultDBType = GitCmdObjectDB
6871if sys .version_info [:2 ] < (2 , 5 ): # python 2.4 compatiblity
6972 DefaultDBType = GitCmdObjectDB
@@ -871,46 +874,15 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):
871874 if progress is not None :
872875 progress = to_progress_instance (progress )
873876
874- # special handling for windows for path at which the clone should be
875- # created.
876- # tilde '~' will be expanded to the HOME no matter where the ~ occours. Hence
877- # we at least give a proper error instead of letting git fail
878- prev_cwd = None
879- prev_path = None
880877 odbt = kwargs .pop ('odbt' , odb_default_type )
881- if is_win :
882- if '~' in path :
883- raise OSError ("Git cannot handle the ~ character in path %r correctly" % path )
884-
885- # on windows, git will think paths like c: are relative and prepend the
886- # current working dir ( before it fails ). We temporarily adjust the working
887- # dir to make this actually work
888- match = re .match ("(\w:[/\\ \])(.*)" , path )
889- if match :
890- prev_cwd = os .getcwd ()
891- prev_path = path
892- drive , rest_of_path = match .groups ()
893- os .chdir (drive )
894- path = rest_of_path
895- kwargs ['with_keep_cwd' ] = True
896- # END cwd preparation
897- # END windows handling
898-
899- try :
900- proc = git .clone (url , path , with_extended_output = True , as_process = True ,
901- v = True , ** add_progress (kwargs , git , progress ))
902- if progress :
903- handle_process_output (proc , None , progress .new_message_handler (), finalize_process )
904- else :
905- (stdout , stderr ) = proc .communicate () # FIXME: Will block of outputs are big!
906- finalize_process (proc , stderr = stderr )
907- # end handle progress
908- finally :
909- if prev_cwd is not None :
910- os .chdir (prev_cwd )
911- path = prev_path
912- # END reset previous working dir
913- # END bad windows handling
878+ proc = git .clone (url , path , with_extended_output = True , as_process = True ,
879+ v = True , ** add_progress (kwargs , git , progress ))
880+ if progress :
881+ handle_process_output (proc , None , progress .new_message_handler (), finalize_process )
882+ else :
883+ (stdout , stderr ) = proc .communicate () # FIXME: Will block of outputs are big!
884+ log .debug ("Cmd(%s)'s unused stdout: %s" , getattr (proc , 'args' , '' ), stdout )
885+ finalize_process (proc , stderr = stderr )
914886
915887 # our git command could have a different working dir than our actual
916888 # environment, hence we prepend its working dir if required
@@ -922,7 +894,7 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs):
922894 # that contains the remote from which we were clones, git stops liking it
923895 # as it will escape the backslashes. Hence we undo the escaping just to be
924896 # sure
925- repo = cls (os . path . abspath ( path ) , odbt = odbt )
897+ repo = cls (path , odbt = odbt )
926898 if repo .remotes :
927899 with repo .remotes [0 ].config_writer as writer :
928900 writer .set_value ('url' , repo .remotes [0 ].url .replace ("\\ \\ " , "\\ " ).replace ("\\ " , "/" ))
0 commit comments