Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitecf37a1

Browse files
committed
index: index-add fixed to always append a newline after each item. In git has unified its way it reads from stdin, now it wants all items to be terminated by a newline usually. Previously, it could have been that it really didn't want to have a termination character when the last item was written to the file. Bumped the minimum requirements to 1.7.0 to be sure it is working as I think it will.
Still, I have to admit that sometime it just appears the closed pipe will not stop git from waiting for more input, at least with the previous implementation
1 parentde84cbd commitecf37a1

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

‎doc/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Requirements
1515
============
1616

1717
*Git_ tested with 1.5.3.7
18-
* RequiresGit_ 1.6.5.4 or newer if index.add function is to be used
18+
* RequiresGit_ 1.7.0 or newer
1919
* `Python Nose`_ - used for running the tests
2020
* `Mock by Michael Foord`_ used for tests. Requires 0.5
2121

‎lib/git/index.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
ifappend_or_prepend_nl<0:
688-
proc.stdin.write('\n')
689-
proc.stdin.write("%s"%filepath)
690-
ifappend_or_prepend_nl>0:
691-
proc.stdin.write('\n')
683+
proc.stdin.write("%s\n"%filepath)
692684
exceptIOError:
693685
# pipe broke, usually because some error happend
694686
raisefmakeexc()
@@ -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
forfilepathinself._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
foreiinnull_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
assertlen(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
forpathinpaths:
13351324
path=self._to_relative_path(path)
@@ -1345,19 +1334,17 @@ def handle_stderr(proc, iter_checked_out_files):
13451334
forentryinself.entries.itervalues():
13461335
ifentry.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
ifnotpath_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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp