The guidelines for git commit ID abbreviation are inconsistent: some places state to use 12 characters exactly, while other places recommend 12 characters or more. The same issue is present in the checkpatch.pl script. E.g. Documentation/dev-tools/checkpatch.rst says: **GIT_COMMIT_ID** The proper way to reference a commit id is: commit <12+ chars of sha1> ("<title line>") However, scripts/checkpatch.pl has two different checks: one warning check accepting 12 characters exactly: # Check Fixes: styles is correct Please use correct Fixes: style 'Fixes: <12 chars of sha1> (\"<title line>\")' and a second error check accepting 12-40 characters: # Check for git id commit length and improperly formed commit descriptions # A correctly formed commit description is: # commit <SHA-1 hash length 12+ chars> ("Complete commit subject") Please use git commit description style 'commit <12+ chars of sha1> Hence patches containing commit IDs with more than 12 characters are flagged by checkpatch, and sometimes rejected by maintainers or reviewers. This is becoming more important with the growth of the repository, as git may decide to use more characters in case of local conflicts. Fix this by settling on at least 12 characters, in both the documentation and in the checkpatch.pl script.
Showing the changes to scripts/checkpatch.pl (1 of 3 files). Show all
Unified · Split
| @@ -3230,7 +3230,7 @@ sub process { · 3229 unmodified lines | ||
| 3230 | 3230 | my $tag_case = not ($tag eq "Fixes:"); |
| 3231 | 3231 | my $tag_space = not ($line =~ /^fixes:? [0-9a-f]{5,40} ($balanced_parens)/i); |
| 3232 | 3232 | |
| 3233 | − my $id_length = not ($orig_commit =~ /^[0-9a-f]{12}$/i); | |
| 3233 | + my $id_length = not ($orig_commit =~ /^[0-9a-f]{12,40}$/i); | |
| 3234 | 3234 | my $id_case = not ($orig_commit !~ /[A-F]/); |
| 3235 | 3235 | |
| 3236 | 3236 | my $id = "0123456789ab"; |
| @@ -3240,7 +3240,7 @@ sub process { · 3 unmodified lines | ||
| 3240 | 3240 | if ($ctitle ne $title || $tag_case || $tag_space || |
| 3241 | 3241 | $id_length || $id_case || !$title_has_quotes) { |
| 3242 | 3242 | if (WARN("BAD_FIXES_TAG", |
| 3243 | − "Please use correct Fixes: style 'Fixes: <12 chars of sha1> (\"<title line>\")' - ie: 'Fixes: $cid (\"$ctitle\")'\n" . $herecurr) && | |
| 3243 | + "Please use correct Fixes: style 'Fixes: <12+ chars of sha1> (\"<title line>\")' - ie: 'Fixes: $cid (\"$ctitle\")'\n" . $herecurr) && | |
| 3244 | 3244 | $fix) { |
| 3245 | 3245 | $fixed[$fixlinenr] = "Fixes: $cid (\"$ctitle\")"; |
| 3246 | 3246 | } |