@@ -661,15 +661,11 @@ def raise_exc(e):
661661 # END path exception handling
662662 # END for each path
663663
664- def _write_path_to_stdin (self , proc , filepath , item , append_or_prepend_nl ,
665- fmakeexc , fprogress , read_from_stdout = True ):
664+ def _write_path_to_stdin (self , proc , filepath , item , fmakeexc , fprogress ,
665+ read_from_stdout = True ):
666666 """Write path to proc.stdin and make sure it processes the item, including progress.
667667
668668 :return: stdout string
669- :param append_or_prepend_nl:
670- * if -1, a newline will be sent before the filepath is printed.
671- * If 1, a newline will be appended after the filepath was printed.
672- * If 0, no additional newline will be sent.
673669 :param read_from_stdout: if True, proc.stdout will be read after the item
674670 was sent to stdin. In that case, it will return None
675671 :note: There is a bug in git-update-index that prevents it from sending
@@ -684,11 +680,7 @@ def _write_path_to_stdin(self, proc, filepath, item, append_or_prepend_nl,
684680 fprogress (filepath , False , item )
685681 rval = None
686682 try :
687- if append_or_prepend_nl < 0 :
688- proc .stdin .write ('\n ' )
689- proc .stdin .write ("%s" % filepath )
690- if append_or_prepend_nl > 0 :
691- proc .stdin .write ('\n ' )
683+ proc .stdin .write ("%s\n " % filepath )
692684 except IOError :
693685 # pipe broke, usually because some error happend
694686 raise fmakeexc ()
@@ -980,10 +972,9 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non
980972 make_exc = lambda : GitCommandError (("git-update-index" ,)+ args , 128 , proc .stderr .read ())
981973 added_files = list ()
982974
983- prepend_newline = 0
984975 for filepath in self ._iter_expand_paths (paths ):
985- self ._write_path_to_stdin (proc , filepath , filepath , prepend_newline , make_exc , fprogress , read_from_stdout = False )
986- prepend_newline = - 1
976+ self ._write_path_to_stdin (proc , filepath , filepath , make_exc ,
977+ fprogress , read_from_stdout = False )
987978 added_files .append (filepath )
988979 # END for each filepath
989980 self ._flush_stdin_and_wait (proc , ignore_stdout = True ) # ignore stdout
@@ -1010,10 +1001,9 @@ def add(self, items, force=True, fprogress=lambda *args: None, path_rewriter=Non
10101001 proc = self .repo .git .hash_object (* args , ** {'istream' :subprocess .PIPE , 'as_process' :True })
10111002 make_exc = lambda : GitCommandError (("git-hash-object" ,)+ args , 128 , proc .stderr .read ())
10121003 obj_ids = list ()
1013- append_newline = 1
10141004 for ei in null_entries_indices :
10151005 entry = entries [ei ]
1016- obj_ids .append (self ._write_path_to_stdin (proc , entry .path , entry , append_newline ,
1006+ obj_ids .append (self ._write_path_to_stdin (proc , entry .path , entry ,
10171007 make_exc , fprogress , read_from_stdout = True ))
10181008 # END for each entry index
10191009 assert len (obj_ids ) == len (null_entries_indices ), "git-hash-object did not produce all requested objects: want %i, got %i" % ( len (null_entries_indices ), len (obj_ids ) )
@@ -1329,7 +1319,6 @@ def handle_stderr(proc, iter_checked_out_files):
13291319 proc = self .repo .git .checkout_index (args , ** kwargs )
13301320 make_exc = lambda : GitCommandError (("git-checkout-index" ,)+ tuple (args ), 128 , proc .stderr .read ())
13311321 checked_out_files = list ()
1332- prepend_newline = 0
13331322
13341323 for path in paths :
13351324 path = self ._to_relative_path (path )
@@ -1345,19 +1334,17 @@ def handle_stderr(proc, iter_checked_out_files):
13451334 for entry in self .entries .itervalues ():
13461335 if entry .path .startswith (dir ):
13471336 p = entry .path
1348- self ._write_path_to_stdin (proc , p , p , prepend_newline ,
1349- make_exc , fprogress , read_from_stdout = False )
1350- prepend_newline = - 1
1337+ self ._write_path_to_stdin (proc , p , p , make_exc ,
1338+ fprogress , read_from_stdout = False )
13511339 checked_out_files .append (p )
13521340 path_is_directory = True
13531341 # END if entry is in directory
13541342 # END for each entry
13551343 # END path exception handlnig
13561344
13571345 if not path_is_directory :
1358- self ._write_path_to_stdin (proc , path , path , prepend_newline ,
1359- make_exc , fprogress , read_from_stdout = False )
1360- prepend_newline = - 1
1346+ self ._write_path_to_stdin (proc , path , path , make_exc ,
1347+ fprogress , read_from_stdout = False )
13611348 checked_out_files .append (path )
13621349 # END path is a file
13631350 # END for each path
0 commit comments