Skip to content

Commit

Permalink
parser: Add missing extended header lines
Browse files Browse the repository at this point in the history
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].

[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>
Closes: #267
(cherry picked from commit 753e457)
  • Loading branch information
pevik authored and stephenfin committed Jun 5, 2019
1 parent b58236e commit 7b14113
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions patchwork/parser.py
Expand Up @@ -760,7 +760,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)
#
Expand Down Expand Up @@ -790,7 +790,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:
Expand Down

0 comments on commit 7b14113

Please sign in to comment.