Skip to content

Commit 44d303e

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: improve Gerrit Change-Id: test
The Gerrit Change-Id: entry is sometimes placed after a Signed-off-by: line. When this occurs, the Gerrit warning is not currently emitted as the first Signed-off-by: signature sets a flag to stop looking. Change the test to add a test for the --- patch separator and emit the warning before any before the --- and also before any diff file name. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Tested-by: John Stultz <john.stultz@linaro.org> Link: http://lkml.kernel.org/r/2f6d5f8766fe7439a116c77ea8cc721a3f2d77a2.camel@perches.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 713a09d commit 44d303e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎scripts/checkpatch.pl‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,7 @@ sub process {
23352335
my $is_binding_patch = -1;
23362336
my $in_header_lines = $file ? 0 : 1;
23372337
my $in_commit_log = 0; #Scanning lines before patch
2338+
my $has_patch_separator = 0; #Found a --- line
23382339
my $has_commit_log = 0; #Encountered lines before patch
23392340
my $commit_log_lines = 0; #Number of commit log lines
23402341
my $commit_log_possible_stack_dump = 0;
@@ -2660,6 +2661,12 @@ sub process {
26602661
}
26612662
}
26622663

2664+
# Check for patch separator
2665+
if ($line =~ /^---$/) {
2666+
$has_patch_separator = 1;
2667+
$in_commit_log = 0;
2668+
}
2669+
26632670
# Check if MAINTAINERS is being updated. If so, there's probably no need to
26642671
# emit the "does MAINTAINERS need updating?" message on file add/move/delete
26652672
if ($line =~ /^\s*MAINTAINERS\s*\|/) {
@@ -2759,10 +2766,10 @@ sub process {
27592766
"A patch subject line should describe the change not the tool that found it\n" . $herecurr);
27602767
}
27612768

2762-
# Check for unwanted Gerrit info
2763-
if ($in_commit_log && $line =~ /^\s*change-id:/i) {
2769+
# Check for Gerrit Change-Ids not in any patch context
2770+
if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) {
27642771
ERROR("GERRIT_CHANGE_ID",
2765-
"Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
2772+
"Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr);
27662773
}
27672774

27682775
# Check if the commit log is in a possible stack dump

0 commit comments

Comments
 (0)