diff mbox series

[1/1] parser: Add missing extended header lines

Message ID 20190505202005.18181-1-petr.vorel@gmail.com
State Accepted
Headers show
Series [1/1] parser: Add missing extended header lines | expand

Commit Message

Petr Vorel May 5, 2019, 8:20 p.m. UTC
Patchwork didn't recognise some patches due missing some extended header
lines (e.g. "old mode" and "new mode" for renaming file mode, see [1]).
Thus adding all modes from git doc [2].

Fixes: #267

[1] https://lists.ozlabs.org/pipermail/patchwork/2019-April/005741.html
[2] https://git-scm.com/docs/git-diff#_generating_patches_with_p

Suggested-by: Veronika Kabatova <vkabatov@redhat.com>
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
 patchwork/parser.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Stephen Finucane June 4, 2019, 3:02 p.m. UTC | #1
On Sun, 2019-05-05 at 22:20 +0200, Petr Vorel wrote:
> Patchwork didn't recognise some patches due missing some extended header
> lines (e.g. "old mode" and "new mode" for renaming file mode, see [1]).
> Thus adding all modes from git doc [2].
> 
> Fixes: #267
> 
> [1] https://lists.ozlabs.org/pipermail/patchwork/2019-April/005741.html
> [2] https://git-scm.com/docs/git-diff#_generating_patches_with_p
> 
> Suggested-by: Veronika Kabatova <vkabatov@redhat.com>
> Signed-off-by: Petr Vorel <petr.vorel@gmail.com>

Apologies for the delay in getting to this. This is merged now, though
I also had to include a follow up to ensure the additional lines were
captured in the diff. 

https://github.com/getpatchwork/patchwork/commit/fc1d7505991474b07638a87c0834157d12e1e476

I'll backport this to stable/2.1 shortly.

Thanks!
Stephen

> ---
>  patchwork/parser.py | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/patchwork/parser.py b/patchwork/parser.py
> index 712780a..633fc71 100644
> --- a/patchwork/parser.py
> +++ b/patchwork/parser.py
> @@ -752,7 +752,7 @@ def parse_patch(content):
>      #  3 -> 4 (@@ line)
>      #  4 -> 5 (patch content)
>      #  5 -> 1 (run out of lines from @@-specifed count)
> -    #  1 -> 6 (rename from / rename to / new file / index)
> +    #  1 -> 6 (extended header lines)
>      #  6 -> 2 (---)
>      #  6 -> 1 (other text)
>      #
> @@ -782,7 +782,15 @@ def parse_patch(content):
>              if line.startswith('--- '):
>                  state = 2
>  
> -            if line.startswith(('rename from ', 'rename to ',
> +            # extended header lines
> +            # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p
> +            if line.startswith(('old mode ', 'new mode ',
> +                                'deleted file mode ',
> +                                'new file mode ',
> +                                'copy from ', 'copy to ',
> +                                'rename from ', 'rename to ',
> +                                'similarity index ',
> +                                'dissimilarity index ',
>                                  'new file mode ', 'index ')):
>                  state = 6
>          elif state == 2:
Petr Vorel June 4, 2019, 3:58 p.m. UTC | #2
Hi Stephen,

> Apologies for the delay in getting to this. This is merged now, though
> I also had to include a follow up to ensure the additional lines were
> captured in the diff. 

> https://github.com/getpatchwork/patchwork/commit/fc1d7505991474b07638a87c0834157d12e1e476
Thanks for merge and fix. I filed one more patch to remove duplicity with extended
header lines:
https://patchwork.ozlabs.org/patch/1109993/

> I'll backport this to stable/2.1 shortly.

> Thanks!
> Stephen


Kind regards,
Petr
diff mbox series

Patch

diff --git a/patchwork/parser.py b/patchwork/parser.py
index 712780a..633fc71 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -752,7 +752,7 @@  def parse_patch(content):
     #  3 -> 4 (@@ line)
     #  4 -> 5 (patch content)
     #  5 -> 1 (run out of lines from @@-specifed count)
-    #  1 -> 6 (rename from / rename to / new file / index)
+    #  1 -> 6 (extended header lines)
     #  6 -> 2 (---)
     #  6 -> 1 (other text)
     #
@@ -782,7 +782,15 @@  def parse_patch(content):
             if line.startswith('--- '):
                 state = 2
 
-            if line.startswith(('rename from ', 'rename to ',
+            # extended header lines
+            # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p
+            if line.startswith(('old mode ', 'new mode ',
+                                'deleted file mode ',
+                                'new file mode ',
+                                'copy from ', 'copy to ',
+                                'rename from ', 'rename to ',
+                                'similarity index ',
+                                'dissimilarity index ',
                                 'new file mode ', 'index ')):
                 state = 6
         elif state == 2: