@@ -525,8 +525,10 @@ def _get_fetch_info_from_stderr(self, proc, progress):
525525 progress_handler = progress .new_message_handler ()
526526
527527 stderr_fetch = open (join (self .repo .git_dir , '%03i_debug_git-python_stderr' % self .fetch_no ), 'wb' )
528- def my_progress_handler (line ):
529- stderr_fetch .write ((line + '\n ' ).encode (defenc ))
528+ for line in proc .stderr :
529+ line = line .decode (defenc )
530+ stderr_fetch .write ((line ).encode (defenc ))
531+ line = line .rstrip ()
530532 for pline in progress_handler (line ):
531533 if line .startswith ('fatal:' ):
532534 raise GitCommandError (("Error when fetching: %s" % line ,), 2 )
@@ -541,12 +543,13 @@ def my_progress_handler(line):
541543 # end
542544
543545 # We are only interested in stderr here ...
544- handle_process_output (proc , None , my_progress_handler , finalize_process )
546+ finalize_process (proc )
545547 stderr_fetch .close ()
546548
547549 # read head information
548550 import shutil
549- shutil .copyfile (join (self .repo .git_dir , 'FETCH_HEAD' ), join (self .repo .git_dir , '%03i_debug_git-python_FETCH_HEAD' % self .fetch_no ))
551+ shutil .copyfile (join (self .repo .git_dir , 'FETCH_HEAD' ),
552+ join (self .repo .git_dir , '%03i_debug_git-python_FETCH_HEAD' % self .fetch_no ))
550553 self .fetch_no += 1
551554 fp = open (join (self .repo .git_dir , 'FETCH_HEAD' ), 'rb' )
552555 fetch_head_info = [l .decode (defenc ) for l in fp .readlines ()]
@@ -615,6 +618,7 @@ def fetch(self, refspec=None, progress=None, **kwargs):
615618 args = [refspec ]
616619
617620 proc = self .repo .git .fetch (self , * args , with_extended_output = True , as_process = True , v = True , ** kwargs )
621+ proc .stdout .close ()
618622 res = self ._get_fetch_info_from_stderr (proc , progress or RemoteProgress ())
619623 if hasattr (self .repo .odb , 'update_cache' ):
620624 self .repo .odb .update_cache ()
@@ -630,6 +634,7 @@ def pull(self, refspec=None, progress=None, **kwargs):
630634 :return: Please see 'fetch' method """
631635 kwargs = add_progress (kwargs , self .repo .git , progress )
632636 proc = self .repo .git .pull (self , refspec , with_extended_output = True , as_process = True , v = True , ** kwargs )
637+ proc .stdout .close ()
633638 res = self ._get_fetch_info_from_stderr (proc , progress or RemoteProgress ())
634639 if hasattr (self .repo .odb , 'update_cache' ):
635640 self .repo .odb .update_cache ()
0 commit comments