From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 219F6C35257 for ; Fri, 2 Oct 2020 23:29:26 +0000 (UTC) Received: by mail.kernel.org (Postfix) id E0C782074B; Fri, 2 Oct 2020 23:29:25 +0000 (UTC) Received: from [192.168.1.64] (unknown [89.36.78.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A096C2072E for ; Fri, 2 Oct 2020 23:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601681365; bh=GmCQMyhEuHdVskGGKJImZ82P/SUFBhA5NOMEqEZQFUU=; h=From:List-Id:To:Subject:Date:In-Reply-To:References:From; b=bu8cwCJnThrFS8p9V4O9lZYv+g2r9RAUKBHPrliK0Bq+3b0bvgBu3UA3zLNQWyy1S dNpEawndhtCkPegejYoYRjMncgxjAUEjoC6MguEeteSVtPO4Ev93EeCekgjJFRaBiF qFBp4CqpTlgnMLNmCWxxFsvx1YsvqP5ANf15MtUc= From: Konstantin Ryabitsev List-Id: To: signatures@kernel.org Subject: [PATCH 02/10] Preserve trailer order by default Date: Fri, 2 Oct 2020 19:29:07 -0400 Message-Id: <20201002232915.1728301-3-konstantin@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002232915.1728301-1-konstantin@linuxfoundation.org> References: <20201002232915.1728301-1-konstantin@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patch-Hashes: v=1; h=sha256; g=74859d419ab06ad2cec4d2d1c0f53cb790b66a66; i=/1fYdTrEhRHGSpZsVNANEdB7n5pEOvKz0Wk6UfuD1hc=; m=D+wyvTZX2DZEAGhKx0phMlzv3W+7tOcF5L38RMj297Y=; p=blR6/AbPWmR/kJT4DR+9EqyJl0A3NRTx+oLKPaYMQX4= X-Patch-Sig: m=pgp; i=konstantin@linuxfoundation.org; s=0xB6C41CE35664996C; b=iHUEABYIAB0WIQR2vl2yUnHhSB5njDW2xBzjVmSZbAUCX3e30gAKCRC2xBzjVmSZbNjtAP9J4Wo NgOnkURqyU4SA9LtopkNOSrbt5x4emFUJvMrGiwD9FJSPKEcGGzWDJBIlfWeoVBBltLHPPpo/mRq8 3C7s4QQ= Per discussion on the users list, preserve the trailer order by default. There is no agreement on whether this is a hard requirement for patches or not, but there is general consensus that the default should be to make as few changes to incoming patches as possible. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 43 +++++++++++++++++++++++++------------------ man/b4.5 | 17 ++++++++--------- man/b4.5.rst | 9 +++++---- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 4325121..2f6d1ba 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -66,7 +66,12 @@ WANTHDRS = [ # [b4] # # remember to end with ,* # trailer-order=link*,fixes*,cc*,reported*,suggested*,original*,co-*,tested*,reviewed*,acked*,signed-off*,* -DEFAULT_TRAILER_ORDER = 'fixes*,reported*,suggested*,original*,co-*,signed-off*,tested*,reviewed*,acked*,cc*,link*,*' +# (another common) +# trailer-order=fixes*,reported*,suggested*,original*,co-*,signed-off*,tested*,reviewed*,acked*,cc*,link*,* +# +# Or use _preserve_ (alias to *) to keep the order unchanged + +DEFAULT_TRAILER_ORDER = '*' LOREADDR = 'https://lore.kernel.org' @@ -300,17 +305,17 @@ class LoreMailbox: pmsg.load_hashes() attid = pmsg.attestation.attid if attid not in self.trailer_map: - self.trailer_map[attid] = set() - self.trailer_map[attid].update(trailers) - pmsg.followup_trailers.update(trailers) + self.trailer_map[attid] = list() + self.trailer_map[attid] += trailers + pmsg.followup_trailers += trailers break if not pmsg.reply: # Could be a cover letter - pmsg.followup_trailers.update(trailers) + pmsg.followup_trailers += trailers break if pmsg.in_reply_to and pmsg.in_reply_to in self.msgid_map: lvl += 1 - trailers.update(pmsg.trailers) + trailers += pmsg.trailers pmsg = self.msgid_map[pmsg.in_reply_to] continue break @@ -321,7 +326,7 @@ class LoreMailbox: continue lmsg.load_hashes() if lmsg.attestation.attid in self.trailer_map: - lmsg.followup_trailers.update(self.trailer_map[lmsg.attestation.attid]) + lmsg.followup_trailers += self.trailer_map[lmsg.attestation.attid] return lser @@ -505,11 +510,11 @@ class LoreSeries: continue if lmsg is not None: if self.has_cover and covertrailers and self.patches[0].followup_trailers: - lmsg.followup_trailers.update(self.patches[0].followup_trailers) + lmsg.followup_trailers += self.patches[0].followup_trailers if addmysob: - lmsg.followup_trailers.add(('Signed-off-by', '%s <%s>' % (usercfg['name'], usercfg['email']))) + lmsg.followup_trailers.append(('Signed-off-by', '%s <%s>' % (usercfg['name'], usercfg['email']))) if addlink: - lmsg.followup_trailers.add(('Link', linkmask % lmsg.msgid)) + lmsg.followup_trailers.append(('Link', linkmask % lmsg.msgid)) if attpolicy != 'off': lore_lookup = False @@ -780,8 +785,8 @@ class LoreMessage: self.charset = 'utf-8' self.has_diff = False self.has_diffstat = False - self.trailers = set() - self.followup_trailers = set() + self.trailers = list() + self.followup_trailers = list() # These are populated by pr self.pr_base_commit = None @@ -879,7 +884,7 @@ class LoreMessage: matches = re.findall(r'^\s*Fixes:[ \t]+([a-f0-9]+\s+\(.*\))\s*$', self.body, re.MULTILINE) if matches: for tvalue in matches: - self.trailers.add(('Fixes', tvalue)) + self.trailers.append(('Fixes', tvalue)) # Do we have something that looks like a person-trailer? matches = re.findall(r'^\s*([\w-]{2,}):[ \t]+(.*<\S+>)\s*$', self.body, re.MULTILINE) @@ -888,17 +893,17 @@ class LoreMessage: if matches: for tname, tvalue in matches: if tname.lower() not in badtrailers: - self.trailers.add((tname, tvalue)) + self.trailers.append((tname, tvalue)) def get_trailers(self, sloppy=False): mismatches = set() if sloppy: return set(self.trailers), mismatches - trailers = set() + trailers = list() for tname, tvalue in self.trailers: if tname.lower() in ('fixes',): - trailers.add((tname, tvalue)) + trailers.append((tname, tvalue)) continue tmatch = False @@ -935,7 +940,7 @@ class LoreMessage: logger.debug(' trailer fuzzy name match') tmatch = True if tmatch: - trailers.add((tname, tvalue)) + trailers.append((tname, tvalue)) else: mismatches.add((tname, tvalue)) @@ -1263,10 +1268,12 @@ class LoreMessage: def fix_trailers(self, trailer_order=None): bheaders, message, btrailers, basement, signature = LoreMessage.get_body_parts(self.body) # Now we add mix-in trailers - trailers = btrailers + list(self.followup_trailers) + trailers = btrailers + self.followup_trailers fixtrailers = list() if trailer_order is None: trailer_order = DEFAULT_TRAILER_ORDER + elif trailer_order in ('preserve', '_preserve_'): + trailer_order = '*' for trailermatch in trailer_order: for trailer in trailers: if trailer in fixtrailers: diff --git a/man/b4.5 b/man/b4.5 index 95876b8..cdbd1d0 100644 --- a/man/b4.5 +++ b/man/b4.5 @@ -316,8 +316,6 @@ Save diff into this file instead of outputting to stdout .B \-c\fP,\fB \-\-color Force color output even when writing to file .UNINDENT -.IP "System Message: WARNING/2 (b4.5.rst:, line 201)" -Option list ends without a blank line; unexpected unindent. .INDENT 0.0 .TP .B \-m AMBOX AMBOX, \-\-compare\-am\-mboxes AMBOX AMBOX @@ -326,7 +324,7 @@ Compare two mbx files prepared with "b4 am" .UNINDENT .UNINDENT .sp -\fIExample\fP: b4 diff +\fIExample\fP: b4 diff \fI\%20200526205322.23465\-1\-mic@digikod.net\fP .SH CONFIGURATION .sp B4 configuration is handled via git\-config(1), so you can store it in @@ -344,13 +342,14 @@ Default configuration, with explanations: midmask = https://lore.kernel.org/r/%s\(aq # # When recording Link: trailers, use this mask - linkmask = https://lore.kernel.org/r/%s\(aq + linkmask = https://lore.kernel.org/r/%s # - # When processing thread trailers, use this order. Can use shell\-globbing - # and must end with ,* - # Common alternative order: + # When processing thread trailers, sort them in this order. + # Can use shell\-globbing and must end with ,* + # Some sorting orders: #trailer\-order=link*,fixes*,cc*,reported*,suggested*,original*,co\-*,tested*,reviewed*,acked*,signed\-off*,* - trailer\-order = fixes*,reported*,suggested*,original*,co\-*,signed\-off*,tested*,reviewed*,acked*,cc*,link*,* + #trailer\-order = fixes*,reported*,suggested*,original*,co\-*,signed\-off*,tested*,reviewed*,acked*,cc*,link*,* + trailer\-order = _preserve_ # # Attestation\-checking configuration parameters # off: do not bother checking attestation @@ -389,7 +388,7 @@ Default configuration, with explanations: # How long to keep downloaded threads in cache (minutes)? cache\-expire = 10 # Used when creating summaries for b4 ty, and can be set to a value like - # thanks\-commit\-url\-mask = https://git.kernel.org/username/c/%.10s + # thanks\-commit\-url\-mask = https://git.kernel.org/username/c/%.12s # See this page for more info on convenient git.kernel.org shorterners: # https://korg.wiki.kernel.org/userdoc/git\-url\-shorterners thanks\-commit\-url\-mask = None diff --git a/man/b4.5.rst b/man/b4.5.rst index 2591a04..9e0d995 100644 --- a/man/b4.5.rst +++ b/man/b4.5.rst @@ -219,11 +219,12 @@ Default configuration, with explanations:: # When recording Link: trailers, use this mask linkmask = https://lore.kernel.org/r/%s # - # When processing thread trailers, use this order. Can use shell-globbing - # and must end with ,* - # Common alternative order: + # When processing thread trailers, sort them in this order. + # Can use shell-globbing and must end with ,* + # Some sorting orders: #trailer-order=link*,fixes*,cc*,reported*,suggested*,original*,co-*,tested*,reviewed*,acked*,signed-off*,* - trailer-order = fixes*,reported*,suggested*,original*,co-*,signed-off*,tested*,reviewed*,acked*,cc*,link*,* + #trailer-order = fixes*,reported*,suggested*,original*,co-*,signed-off*,tested*,reviewed*,acked*,cc*,link*,* + trailer-order = _preserve_ # # Attestation-checking configuration parameters # off: do not bother checking attestation -- 2.26.2