Re: [RFC][PATCH] checkpatch: Properly warn if Change-Id comes after first Signed-off-by line

From: Joe Perches
Date: Tue Feb 25 2020 - 13:03:56 EST


On Tue, 2020-02-25 at 09:45 -0800, John Stultz wrote:
> On Mon, Feb 24, 2020 at 10:50 PM Joe Perches <joe@xxxxxxxxxxx> wrote:
> > > Since I have a few kernel repos that I use for both upstream work and
> > > work targeting AOSP trees, I usually have the gerrit commit hook
> > > enabled in my tree (its easier to strip with sed then it is to re-add
> > > after submitting to gerrit), and at least the commit-msg hook I have
> > > will usually append a Change-Id: line at the end of the commit
> > > message, usually after the signed-off-by line.
> >
> > Perhaps this is better:
> > ---
> > scripts/checkpatch.pl | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> > @@ -2721,9 +2721,9 @@ sub process {
> > }
> >
> > # Check for unwanted Gerrit info
> > - if ($in_commit_log && $line =~ /^\s*change-id:/i) {
> > + if ($realfile eq '' && $line =~ /^\s*change-id:/i) {
> > ERROR("GERRIT_CHANGE_ID",
> > - "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
> > + "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr);
> > }
> >
> > # Check if the commit log is in a possible stack dump
> >
>
> Yep. This works well for me, catching Change-Id lines that are missed
> by the current code.
>
> Tested-by: John Stultz <john.stultz@xxxxxxxxxx>

A negative approach to this is if the change-id is after
the "---" separator line but before any file diff, then the
"Remove Gerrit Change-Id" message will still be emitted.

Dunno if that's an issue.