From b216f8311a3e4eb4bf637ec11f40fdd0c65585a0 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 25 Jul 2020 23:41:14 -0400 Subject: Fix basement detection for empty commit message bodies 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 Signed-off-by: Konstantin Ryabitsev --- 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 @@ class LoreMessage: 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: -- cgit v1.2.3