checkpatch: remove false warning for commit reference
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 10 Jul 2017 22:52:16 +0000 (15:52 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 10 Jul 2017 23:32:35 +0000 (16:32 -0700)
Checkpatch warns of an incorrect commit reference style for any
hexadecimal number of 12 digits and more.

Numbers of 12 digits are not necessarily commit ids.

For an example provoking the problem see
  https://patchwork.kernel.org/patch/9170897/

Checkpatch should only warn if the number refers to an existing commit.

Link: http://lkml.kernel.org/r/20170607184008.5869-1-xypron.glpk@gmx.de
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 2f61f54b8940787f9575b590edac5df325e52744..e9618ca312513922a42f0296361ac967060d79b8 100755 (executable)
@@ -867,6 +867,7 @@ sub git_commit_info {
 #                  echo "commit $(cut -c 1-12,41-)"
 #              done
        } elsif ($lines[0] =~ /^fatal: ambiguous argument '$commit': unknown revision or path not in the working tree\./) {
+               $id = undef;
        } else {
                $id = substr($lines[0], 0, 12);
                $desc = substr($lines[0], 41);
@@ -2606,7 +2607,8 @@ sub process {
                        ($id, $description) = git_commit_info($orig_commit,
                                                              $id, $orig_desc);
 
-                       if ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) {
+                       if (defined($id) &&
+                          ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
                                ERROR("GIT_COMMIT_ID",
                                      "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
                        }