@@ -775,22 +775,26 @@ def expand_paths(paths):
775775 return out
776776 # END expand helper method
777777
778- def write_path_to_stdin (proc , filepath , item , fmakeexc ):
778+ def write_path_to_stdin (proc , filepath , item , fmakeexc , read_from_stdout = True ):
779779 """Write path to proc.stdin and make sure it processes the item, including progress.
780- @return: stdout string"""
780+ @return: stdout string
781+ @param read_from_stdout: if True, proc.stdout will be read after the item
782+ was sent to stdin. In that case, it will return None
783+ @note: There is a bug in git-update-index that prevents it from sending
784+ reports just in time. This is why we have a version that tries to
785+ read stdout and one which doesn't. In fact, the stdout is not
786+ important as the piped-in files are processed anyway and just in time"""
781787 fprogress (filepath , False , item )
788+ rval = None
782789 try :
783790 proc .stdin .write ("%s\n " % filepath )
784791 except IOError :
785792 # pipe broke, usually because some error happend
786793 raise fmakeexc ()
787- # END write exception handling
794+ # END write exception handling
788795 proc .stdin .flush ()
789- # NOTE: if this hangs, you need at lest git 1.6.5.4 as a git-bugfix
790- # is needed for this
791- # TODO: Rewrite this using hash-object and update index to get
792- # rid of the bug-fix dependency, updaet intro.rst requirements
793- rval = proc .stdout .readline ().strip () # trigger operation
796+ if read_from_stdout :
797+ rval = proc .stdout .readline ().strip ()
794798 fprogress (filepath , True , item )
795799 return rval
796800 # END write_path_to_stdin
@@ -804,15 +808,15 @@ def write_path_to_stdin(proc, filepath, item, fmakeexc):
804808
805809 # HANDLE PATHS
806810 if paths :
807- # to get suitable progress information, pipe paths to stdin
811+ # to get suitable progress information, pipe paths to stdin
808812 args = ("--add" , "--replace" , "--verbose" , "--stdin" )
809813 proc = self .repo .git .update_index (* args , ** {'as_process' :True , 'istream' :subprocess .PIPE })
810814 make_exc = lambda : GitCommandError (("git-update-index" ,)+ args , 128 , proc .stderr .readline ())
811815 filepaths = expand_paths (paths )
812816 added_files = list ()
813817
814818 for filepath in filepaths :
815- write_path_to_stdin (proc , filepath , filepath , make_exc )
819+ write_path_to_stdin (proc , filepath , filepath , make_exc , read_from_stdout = False )
816820 added_files .append (filepath )
817821 # END for each filepath
818822 self ._flush_stdin_and_wait (proc ) # ignore stdout
0 commit comments