From patchwork Wed Apr 13 11:12:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2] Ensure consecutive patch header lines Date: Wed, 13 Apr 2011 01:12:21 -0000 From: Dirk Wallenstein X-Patchwork-Id: 90985 Message-Id: <20110413111221.GA21237@bottich> To: Jeremy Kerr Cc: patchwork@lists.ozlabs.org Drop the parse buffer if the start of a new diff is encountered in state 1. Signed-off-by: Dirk Wallenstein --- v2: On Mon, Feb 28, 2011 at 09:29:13AM +0800, Jeremy Kerr wrote: > I think a nicer fix would be to drop the current parse buffer (ie, make it > part of the comment) if we see '^diff' again, rather than allowing for only > one line between '^diff' and '^--- '. This way we should only see entire hunks > ending up in the patch bufffer. Sorry for the holdup. I lost this TODO somewhere. apps/patchwork/parser.py | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py index 2b5e9a0..a432f4f 100644 --- a/apps/patchwork/parser.py +++ b/apps/patchwork/parser.py @@ -81,6 +81,11 @@ def parse_patch(text): commentbuf += line elif state == 1: + if line.startswith('diff') or line.startswith('===') \ + or line.startswith('Index: '): + commentbuf += buf + buf = '' + buf += line if line.startswith('--- '): state = 2