Yann E. MORIN  committed 515822a

patchmessage: detect SoB-block

The Message-Id line is intended to belong to a SoB-block, that is,
a set of SoB-like lines (SoB, Acked, Tested...). In this case, just
append the Message-Id line without a preceding blank line.

On the other hand, if a SoB-block is missing (because the project does
not use or enforce SoB-lines), but still want to use the Message-Id
line, it makes sense to append the MEssage-Id line with a preceding
blank line, to properly separate it from the original commit log.

Use a rather crude heuristic to detect presence of a SoB-block by
matching lines against a regexp with all known-today SoB-like lines.

Signed-off-by: "Yann E. MORIN" <>

  • Participants
  • Parent commits 5f761b0
  • Branches default

Comments (0)

Files changed (2)

                           r'retrieving revision [0-9]+(\.[0-9]+)*$|'
                           r'---[ \t].*?^\+\+\+[ \t]|'
                           r'\*\*\*[ \t].*?^---[ \t])', re.MULTILINE|re.DOTALL)
+re_sob = re.compile(r'^((Signed-off|Reported|Tested|Reviewed|Acked)-by|Cc):',
+                    re.MULTILINE|re.DOTALL)
 def parsesubject(s):
     """Return unbroken subject, title, index and total count from
         if messageid:
             m =
             if m:
+                # Do we have a SoB-block?
+                if[:m.start(0)-1]):
+                    sep = ''        # Yes, no separator line
+                else:
+                    sep = '\n'      # No, add separator line
                 # Insert a Message-Id line
-                patch = patch[:m.start(0)-1]            + \
+                patch = patch[:m.start(0)-1] + sep      + \
                         'Message-Id: ' + + '\n' + \
         return patch

File test-mbox.out
 test no SoB-block
 Message-Id: <5ab3c4562bd574dbd782.1230599538@localhost>
 diff --git a/a b/a