Skip to contentSkip to conversation

Handle author A, submitter B, committer A SOB chain correctly

PATCH New Thomas Gleixner 1 participant 1 message Mar 3, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Handle author A, submitter B, committer A SOB chain correctly

The trailer handling of b4 fails to handle one particular case correctly:

Dev A posts a patch with his SOB

Subject: [PATCH] subsys: Something
From: Dev A <[email protected]>

Some explanation

Dev B picks the patch up, adds his SOB and reposts it in a follow up series:

Subject: [PATCH v2 1/5] subsys: Something
From: Dev B <[email protected]>

From: Dev A <[email protected]>

Some explanation

Now Dev A who is also the maintainer picks the series up and b4 converts it to:

Author: Dev A <[email protected]>

subsys: Something

Some explanation

While Dev A is correctly assigned to be the author of the commit, the SOB chain is incorrect because the first SOB is not the author's SOB. The correct resolution for this is:

Author: Dev A <[email protected]>

subsys: Something

Some explanation

Validate that the committers SOB is the last one in the SOB chain and only remove it from processing if that's true. If the committers SOB is before the last SOB in the submission, then keep the ordering intact and add an extra committer SOB at the end.

---
 src/b4/__init__.py |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
src/b4/__init__.py +15 -2
@@ -2205,9 +2205,22 @@ MAILMAP_INFO = dict()
         sobtr = LoreTrailer()
         hasmysob = False
         if sobtr in btrailers:
+
+            found = False
+            last = True
+            for bltr in btrailers:
+                if not found:
+                    found = bltr == sobtr
+                else:
+                    if bltr.lname == 'signed-off-by':
+                        last = False
+                        break
+
             # Our own signoff always moves to the bottom of all trailers
-            hasmysob = True
-            btrailers.remove(sobtr)
+            # if it is the last signoff in the chain.
+            if last:
+                hasmysob = True
+                btrailers.remove(sobtr)
 
         new_trailers = self.followup_trailers
         if extras: