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.
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -2335,6 +2335,7 @@ sub process { · 2334 unmodified lines | ||
| 2335 | 2335 | my $is_binding_patch = -1; |
| 2336 | 2336 | my $in_header_lines = $file ? 0 : 1; |
| 2337 | 2337 | my $in_commit_log = 0; #Scanning lines before patch |
| 2338 | + my $has_patch_separator = 0; #Found a --- line | |
| 2338 | 2339 | my $has_commit_log = 0; #Encountered lines before patch |
| 2339 | 2340 | my $commit_log_lines = 0; #Number of commit log lines |
| 2340 | 2341 | my $commit_log_possible_stack_dump = 0; |
| @@ -2660,6 +2661,12 @@ sub process { · 319 unmodified lines | ||
| 2660 | 2661 | } |
| 2661 | 2662 | } |
| 2662 | 2663 | |
| 2664 | +# Check for patch separator | |
| 2665 | + if ($line =~ /^---$/) { | |
| 2666 | + $has_patch_separator = 1; | |
| 2667 | + $in_commit_log = 0; | |
| 2668 | + } | |
| 2669 | + | |
| 2663 | 2670 | # Check if MAINTAINERS is being updated. If so, there's probably no need to |
| 2664 | 2671 | # emit the "does MAINTAINERS need updating?" message on file add/move/delete |
| 2665 | 2672 | if ($line =~ /^\s*MAINTAINERS\s*\|/) { |
| @@ -2759,10 +2766,10 @@ sub process { · 93 unmodified lines | ||
| 2759 | 2766 | "A patch subject line should describe the change not the tool that found it\n" . $herecurr); |
| 2760 | 2767 | } |
| 2761 | 2768 | |
| 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) { | |
| 2764 | 2771 | 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); | |
| 2766 | 2773 | } |
| 2767 | 2774 | |
| 2768 | 2775 | # Check if the commit log is in a possible stack dump |