History

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.

Joe Perches committed 6 years ago

Commit 44d303e1 parent 713a09d1 file · +10 −3Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+10−3
@@ -2335,6 +2335,7 @@ sub process { · 2334 unmodified lines
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 { · 319 unmodified lines
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 { · 93 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t