[v2] Ensure consecutive patch header lines

Submitted by Dirk Wallenstein on April 13, 2011, 11:12 a.m.

Details

Message ID 20110413111221.GA21237@bottich
State Accepted
Headers show

Commit Message

Dirk Wallenstein April 13, 2011, 11:12 a.m.
Drop the parse buffer if the start of a new diff is encountered in
state 1.

Signed-off-by: Dirk Wallenstein <halsmit@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(-)

Comments

Jeremy Kerr April 14, 2011, 7:15 a.m.
Hi Dirk,

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

Looks good, applied. No problem about the holdup :)

Cheers,


Jeremy

Patch hide | download patch | download mbox

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