Re: StGIT cannot import properly from stdin
Catalin Marinas <catalin.marinas@gmail.com> wrote:
> It works, thanks for this. I attached a patch if you want to try.
Oops, gmail attached it as a binary. It is inserted below (as text/plain):
====================================================== Fix importing from stdin
The current stdin patch importing expects two EOFs since the 'for' loop doesn't start before one EOF is received. As suggested, this patch changes the 'for' loop with a 'while True' loop.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
---
stgit/commands/imprt.py | 6 +++++-
stgit/git.py | 5 ++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -134,7 +134,11 @@ def __parse_patch(filename = None):
authname = authemail = authdate = None
descr = ''
- for line in f:
+ while True:
+ line = f.readline()
+ if not line:
+ break
+
# the first 'Signed-of-by:' is the author
if not authname and re.match('signed-off-by:\s+', line, re.I):
auth = re.findall('^.*?:\s+(.*)$', line)[0]
diff --git a/stgit/git.py b/stgit/git.py
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -113,7 +113,10 @@ def get_conflicts():
def _input(cmd, file_desc):
p = popen2.Popen3(cmd)
- for line in file_desc:
+ while True:
+ line = file_desc.readline()
+ if not line:
+ break
p.tochild.write(line)
p.tochild.close()
if p.wait():