git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@gmail.com>
To: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: git@vger.kernel.org
Subject: Re: StGIT cannot import properly from stdin
Date: Thu, 22 Sep 2005 16:42:28 +0100	[thread overview]
Message-ID: <b0943d9e050922084232f704d@mail.gmail.com> (raw)
In-Reply-To: <4332C880.1060906@drzeus.cx>

[-- Attachment #1: Type: text/plain, Size: 277 bytes --]

On 22/09/05, Pierre Ossman <drzeus-list@drzeus.cx> wrote:
> Bummer. I checked with the local Python guru here and he suggested
> changing the for loop to an infinite while and f.readline().

It works, thanks for this. I attached a patch if you want to try.

--
Catalin

[-- Attachment #2: import-stdin --]
[-- Type: application/octet-stream, Size: 1313 bytes --]

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():

  reply	other threads:[~2005-09-22 15:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-21  7:12 StGIT cannot import properly from stdin Pierre Ossman
2005-09-21  8:03 ` Catalin Marinas
2005-09-22 11:08   ` Pierre Ossman
2005-09-22 12:11     ` Catalin Marinas
2005-09-22 14:05       ` Pierre Ossman
2005-09-22 14:34         ` Catalin Marinas
2005-09-22 15:06           ` Pierre Ossman
2005-09-22 15:42             ` Catalin Marinas [this message]
2005-09-22 15:48               ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0943d9e050922084232f704d@mail.gmail.com \
    --to=catalin.marinas@gmail.com \
    --cc=drzeus-list@drzeus.cx \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).