diff mbox

[U-Boot,v2,2/5] tools: patman: Handle tag sections without an 'END'

Message ID 1467008672-1116-3-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit 13b98d95bab89bcac75c8a187577e7cc3754d194
Delegated to: Simon Glass
Headers show

Commit Message

Bin Meng June 27, 2016, 6:24 a.m. UTC
'Cover-letter', 'Series-notes' and 'Commit-notes' tags require an
'END' to be put at the end of its section. If we forget to put an
'END' in those sections, and these sections are followed by another
patman tag, patman generates incorrect patches. This adds codes to
handle such scenario.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>

---

Changes in v2:
- Update commit message to explain when such scenario is hit
- Add cover_match to the test logic
- Generate warning for missing 'END' case

 tools/patman/patchstream.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Simon Glass July 3, 2016, 11:26 p.m. UTC | #1
On 27 June 2016 at 00:24, Bin Meng <bmeng.cn@gmail.com> wrote:
> 'Cover-letter', 'Series-notes' and 'Commit-notes' tags require an
> 'END' to be put at the end of its section. If we forget to put an
> 'END' in those sections, and these sections are followed by another
> patman tag, patman generates incorrect patches. This adds codes to
> handle such scenario.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Acked-by: Simon Glass <sjg@chromium.org>
>
> ---
>
> Changes in v2:
> - Update commit message to explain when such scenario is hit
> - Add cover_match to the test logic
> - Generate warning for missing 'END' case
>
>  tools/patman/patchstream.py | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>

Applied to u-boot-dm/next, thanks!
diff mbox

Patch

diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index 2c4efc5..ce8ffb8 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -169,6 +169,26 @@  class PatchStream:
         elif commit_match:
             self.state = STATE_MSG_HEADER
 
+        # If a tag is detected, but we are already in a section,
+        # this means 'END' is missing for that section, fix it up.
+        if series_tag_match or commit_tag_match or \
+           cover_match or cover_cc_match or signoff_match:
+            if self.in_section:
+                self.warn.append("Missing 'END' in section '%s'" % self.in_section)
+                if self.in_section == 'cover':
+                    self.series.cover = self.section
+                elif self.in_section == 'notes':
+                    if self.is_log:
+                        self.series.notes += self.section
+                elif self.in_section == 'commit-notes':
+                    if self.is_log:
+                        self.commit.notes += self.section
+                else:
+                    self.warn.append("Unknown section '%s'" % self.in_section)
+                self.in_section = None
+                self.skip_blank = True
+                self.section = []
+
         # If we are in a section, keep collecting lines until we see END
         if self.in_section:
             if line == 'END':