Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp850908pxb; Thu, 19 Aug 2021 12:53:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHn9nzDj1iKpGE1zwWdcu9YfG5ZFve/o3GDjsEKMGTCIlfBtM7lzSPGnJpExE1PoBJJa5n X-Received: by 2002:a05:6e02:1b8f:: with SMTP id h15mr10945584ili.37.1629402839147; Thu, 19 Aug 2021 12:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629402839; cv=none; d=google.com; s=arc-20160816; b=SEA0Ohda5j86fGeVq9D84rm47uCucOn1DNDTsHV2OKa1RgrZzxVgoANYI8vWMMRBnq NMYeatRFxwhzaYWCHZSxn9lXOvKb0tkR3bkhXvNTPHf2yuGQf+KNyrSKi0kJWEhSdMbB 9xbsRfeIRYIkjcHvqDy26FVaYdwkeEGM4gx7QtRYBGeHatVT6W51KFYQ6dZ6anYos+F+ SutGI7pyIX1/6FW2dGL4XWVxtrOcLSZLhVOZEom10ik4pUaTE8xuOVTUN2THtwU21yjI T3locSbAmAwQUJfEZb3Ua7i6c8wRK2B/qAHbUlBZsmCwbtILmiN6899EIA9A885JNERP oYBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=yYuu4lI5p7DoBEaNzy386yfHwqBF6DSycUzLzLrgD2s=; b=rOAuWuw4SmFaJ51m/i4kAowUOhYs6wYuvv8Ge3oPnjBC7bH14xbMpZkownvdwGstRU pm+8GWgbxp84A/V8gBH3xmBGA4Sl3uEbhtvR4xGWeskDRyN+sgfgoGQ11BMyHCFR+EVK 35rjKI2676B0n3IicmQKvnAAQAGKK/IRxIzbAsrxFGsUImJrjtg6OM/dRfOjcZ2w+gv+ XJhuaTaKxluwRZGArUEYIqEqhcCOvzS633WlA/Qt0J3fMsOonB8G9lCeg7xcz6C2GNjy fEpdgfTFm1i8cSMOqYx0Md9/05rCN4iVhA0pywbS3lLxoXbLu+DukVPEVdQjPjyuIFqy 9v6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y28si3614592iot.48.2021.08.19.12.53.47; Thu, 19 Aug 2021 12:53:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234640AbhHSTxP (ORCPT + 99 others); Thu, 19 Aug 2021 15:53:15 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:39441 "EHLO mail-io1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233792AbhHSTxO (ORCPT ); Thu, 19 Aug 2021 15:53:14 -0400 Received: by mail-io1-f42.google.com with SMTP id a21so9241332ioq.6; Thu, 19 Aug 2021 12:52:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yYuu4lI5p7DoBEaNzy386yfHwqBF6DSycUzLzLrgD2s=; b=FPIlJITyl8PTEG88QMniDnGFq4psg9paW/jju+NQVgtRFoKB2Y8pyiDfL9VwV7HdIQ ZTmxsvQPjqJ5UmGIcw8j8Qhjsi505vCVpc8bOBAPX8hHcw86GevrpCzbOQGCjaXVylXa 7WHv076E9RH+2HjmgeOVN+caWKkaz4JK41zqExOsq1OyGilr+Simss14pLYYXKC8JRRe jFJh6+ZLHPzQl5Zth5L+tMIbpOPyVJ68B55vngooy5ke5bgHaQdwP4WnqH3s7E8SWcqG aDg9HCRatrinoF5zkm0GTepcUngMdYv4e4qbN/rsFP19zVRNND33XwVCIL4cYBS8sJiY Sqzw== X-Gm-Message-State: AOAM532otfIee+JxzvjNOnawrFvauN5FS9SCCRQTElbWUjzTKuP9OaiG HiSILmFIngrBLKcbsi7eFHQ= X-Received: by 2002:a05:6602:2219:: with SMTP id n25mr12516872ion.185.1629402757172; Thu, 19 Aug 2021 12:52:37 -0700 (PDT) Received: from [192.168.1.109] ([213.87.152.233]) by smtp.gmail.com with ESMTPSA id x1sm2162535ilg.33.2021.08.19.12.52.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Aug 2021 12:52:36 -0700 (PDT) Subject: Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits To: Joe Perches , linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe , Jiri Kosina , Willy Tarreau References: <20210818154646.925351-1-efremov@linux.com> <20210818154646.925351-2-efremov@linux.com> <3d347d4b-1576-754f-8633-ba6084cc0661@linux.com> <23c8ebaa0921d5597df9fc1d6cbbcc4f354f80c5.camel@perches.com> From: Denis Efremov Message-ID: Date: Thu, 19 Aug 2021 22:52:29 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <23c8ebaa0921d5597df9fc1d6cbbcc4f354f80c5.camel@perches.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 8/19/21 12:22 AM, Joe Perches wrote: > Hey Denis: > > Try this one please and let me know what you think... Looks good to me. Couple of nitpicks below > > --- > scripts/checkpatch.pl | 31 +++++++++++++------------------ > 1 file changed, 13 insertions(+), 18 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 161ce7fe5d1e5..4e2e79eff9b8c 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -3196,26 +3196,21 @@ sub process { > $orig_commit = lc($1); > } > > - $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i); > - $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i); > - $space = 0 if ($line =~ /\bcommit [0-9a-f]/i); > - $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/); > - if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) { > - $orig_desc = $1; > - $hasparens = 1; > - } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i && > - defined $rawlines[$linenr] && > - $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) { > - $orig_desc = $1; > - $hasparens = 1; > - } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i && > - defined $rawlines[$linenr] && > - $rawlines[$linenr] =~ /^\s*[^"]+"\)/) { > - $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i; > + my $input = $line; > + for (my $n = 0; $n < 2; $n++) { > + $input .= " $rawlines[$linenr + $n]" if ($#lines >= $linenr + $n); > + } > + > + $short = 0 if ($input =~ /\bcommit\s+[0-9a-f]{12,40}/i); > + $long = 1 if ($input =~ /\bcommit\s+[0-9a-f]{41,}/i); > + $space = 0 if ($input =~ /\bcommit [0-9a-f]/i); > + $case = 0 if ($input =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/); > + if ($input =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/i) { > $orig_desc = $1; > - $rawlines[$linenr] =~ /^\s*([^"]+)"\)/; > - $orig_desc .= " " . $1; > $hasparens = 1; > + # Always strip leading/trailing parens then double quotes if existing > + $orig_desc = substr($orig_desc, 1, -1); > + $orig_desc = substr($orig_desc, 1, -1) if ($orig_desc =~ /^".*"$/); Why do you want to add "if ($orig_desc =~ /^".*"$/);" here? and not just substr($orig_desc, 2, -2);? > } > > ($id, $description) = git_commit_info($orig_commit, > In your previous patch with '.*?' you added a branch to allow also newlines between commit and shas: ``` commit c3f157259438 (Revert "floppy: reintroduce O_NDELAY fix") ``` Maybe something like this will work (adding a last word from a prevline if line doesn't start from commit) + my $input = $line; if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) { $init_char = $1; $orig_commit = lc($2); } elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) { $orig_commit = lc($1); + $prevline =~ /(\w+)$/; + $line = $1 . " " . $prevline; } - my $input = $line; for (my $n = 0; $n < 2; $n++) { $input .= " $rawlines[$linenr + $n]" if ($#lines >= $linenr + $n); } Thanks, Denis