From: Catalin Marinas Date: Thu, 22 Sep 2005 16:43:36 +0000 (+0100) Subject: Fix importing from stdin X-Git-Tag: v0.7~10 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/6fe6b1bd5137323248b696989c41ebb7b98514cc 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 --- diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py index 24c7429..9001639 100644 --- a/stgit/commands/imprt.py +++ b/stgit/commands/imprt.py @@ -87,7 +87,10 @@ def __parse_mail(filename = None): descr = authname = authemail = authdate = None # parse the headers - for line in f: + while True: + line = f.readline() + if not line: + break line = line.strip() if re.match('from:\s+', line, re.I): auth = re.findall('^.*?:\s+(.*)$', line)[0] @@ -109,7 +112,10 @@ def __parse_mail(filename = None): raise CmdException, 'Subject: line not found' # the rest of the patch description - for line in f: + while True: + line = f.readline() + if not line: + break if re.match('---\s*$', line) or re.match('diff -', line) or \ re.match('^Index: ', line): break @@ -134,7 +140,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 index 293d421..7ab9aef 100644 --- 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():