Linux maintainer tooling and workflows
 help / color / Atom feed
* [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts()
@ 2020-07-26  3:41 kyle
  2020-07-26  3:41 ` [PATCH b4 1/2] Fix basement detection for empty commit message bodies Kyle Meyer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: kyle @ 2020-07-26  3:41 UTC (permalink / raw)
  To: tools

After using 'b4 am' to grab a series from public-inbox meta [0], I
noticed that many of the commit message bodies were missing.  It turns
out that this happens when a message body consists of only a single,
non-trailer paragraph.

The second patch fixes this.  The first patch addresses another issue
I spotted when debugging the dropped commit messages.

[0]: https://public-inbox.org/meta/20200724055606.27332-1-e@yhbt.net


  [1/2] Fix basement detection for empty commit message bodies
  [2/2] Fix handling of single-paragraph commit message bodies

 b4/__init__.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


base-commit: 2737ccdd3dbf58e330ace3ec658511bfbd715059
-- 
2.27.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH b4 1/2] Fix basement detection for empty commit message bodies
  2020-07-26  3:41 [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() kyle
@ 2020-07-26  3:41 ` Kyle Meyer
  2020-07-26  3:41 ` [PATCH b4 2/2] Fix handling of single-paragraph " Kyle Meyer
  2020-07-27 14:08 ` [tools] [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() Konstantin Ryabitsev
  2 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2020-07-26  3:41 UTC (permalink / raw)
  To: tools

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH b4 2/2] Fix handling of single-paragraph commit message bodies
  2020-07-26  3:41 [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() kyle
  2020-07-26  3:41 ` [PATCH b4 1/2] Fix basement detection for empty commit message bodies Kyle Meyer
@ 2020-07-26  3:41 ` Kyle Meyer
  2020-07-27 14:08 ` [tools] [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() Konstantin Ryabitsev
  2 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2020-07-26  3:41 UTC (permalink / raw)
  To: tools

The get_body_parts() method added in ba6c790 (Parse body parts into
usual chunks, 2020-04-27) strips lines that look like trailers from
the last paragraph, storing the other lines to add back to the
message.  However, if the commit message has only a single paragraph,
get_body_parts() returns early, unconditionally returning an empty
string for the message even if non-trailer lines were encountered.

Return the collected non-trailer lines, if any, as the message.

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

diff --git a/b4/__init__.py b/b4/__init__.py
index 7e3134f..b7b33f4 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -1241,6 +1241,8 @@ def get_body_parts(body):
             if githeaders == trailers:
                 # This is a message that consists of just trailers?
                 githeaders = list()
+            if nlines:
+                message = '\n'.join(nlines)
             return githeaders, message, trailers, basement, signature
 
         # Add all parts between first and last to mparts
-- 
2.27.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [tools] [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts()
  2020-07-26  3:41 [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() kyle
  2020-07-26  3:41 ` [PATCH b4 1/2] Fix basement detection for empty commit message bodies Kyle Meyer
  2020-07-26  3:41 ` [PATCH b4 2/2] Fix handling of single-paragraph " Kyle Meyer
@ 2020-07-27 14:08 ` Konstantin Ryabitsev
  2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Ryabitsev @ 2020-07-27 14:08 UTC (permalink / raw)
  To: tools, kyle

On Sat, Jul 25, 2020 at 11:41:13PM -0400, Kyle Meyer wrote:
> After using 'b4 am' to grab a series from public-inbox meta [0], I
> noticed that many of the commit message bodies were missing.  It turns
> out that this happens when a message body consists of only a single,
> non-trailer paragraph.
> 
> The second patch fixes this.  The first patch addresses another issue
> I spotted when debugging the dropped commit messages.

Thanks, applied both to  master and stable-0.5.y. I guess I'm so used to 
trailers that I haven't considered cases where there are commits without 
them. :)

-K

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-26  3:41 [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() kyle
2020-07-26  3:41 ` [PATCH b4 1/2] Fix basement detection for empty commit message bodies Kyle Meyer
2020-07-26  3:41 ` [PATCH b4 2/2] Fix handling of single-paragraph " Kyle Meyer
2020-07-27 14:08 ` [tools] [PATCH b4 0/2] Two fixes for LoreMessage.get_body_parts() Konstantin Ryabitsev

Linux maintainer tooling and workflows

Archives are clonable:
	git clone --mirror https://lore.kernel.org/tools/0 tools/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tools tools/ https://lore.kernel.org/tools \
		tools@linux.kernel.org
	public-inbox-index tools

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.linux.tools


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git