[PATCH v2] Ensure consecutive patch header lines

Dirk Wallenstein halsmit at t-online.de
Wed Apr 13 21:12:21 EST 2011


Drop the parse buffer if the start of a new diff is encountered in
state 1.

Signed-off-by: Dirk Wallenstein <halsmit at t-online.de>
---

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
-- 
1.7.4.2



More information about the Patchwork mailing list