tools.linux.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kyle Meyer" <kyle@kyleam.com>
To: tools@linux.kernel.org
Subject: [PATCH b4 1/2] Fix basement detection for empty commit message bodies
Date: Sat, 25 Jul 2020 23:41:14 -0400	[thread overview]
Message-ID: <20200726034115.21567-2-kyle@kyleam.com> (raw)
In-Reply-To: <20200726034115.21567-1-kyle@kyleam.com>

The get_body_parts() method added in ba6c790 (Parse body parts into
usual chunks, 2020-04-27) splits the commit message body on "\n---\n"
and takes the second half as the "basement" of the patch.  The body is
stripped of flanking new lines, though, so a delimiter beginning with
a new line isn't appropriate for commit messages without a message
body.  Make the starting new line optional.

Note that this doesn't matter in the end in terms of the final applied
patch.  Before 31f33fd (Fix body part parsing when '---' is not used,
2020-06-08), the expected patch output was produced despite the diff
lines being processed as the message body.  After that commit, the
information following the triple dash is a bit off, but it doesn't
matter because git discards it anyway.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
---
 b4/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/b4/__init__.py b/b4/__init__.py
index de6a274..7e3134f 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -1204,7 +1204,7 @@ def get_body_parts(body):
             signature = sparts[1]
             body = sparts[0].rstrip('\n')
 
-        parts = body.split('\n---\n', 1)
+        parts = re.split('^---\n', body, maxsplit=1, flags=re.M)
         if len(parts) == 2:
             basement = parts[1].rstrip('\n')
         elif body.find('\ndiff ') >= 0:
-- 
2.27.0


  reply	other threads:[~2020-07-26  3:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-26  3:41 [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() kyle
2020-07-26  3:41 ` Kyle Meyer [this message]
2020-07-26  3:41 ` [PATCH b4 2/2] Fix handling of single-paragraph commit message bodies Kyle Meyer
2020-07-27 14:08 ` [tools] [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() Konstantin Ryabitsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200726034115.21567-2-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=tools@linux.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).