]> git.proxmox.com Git - mirror_qemu.git/commitdiff
checkpatch: consider git extended headers valid patches
authorStefan Hajnoczi <stefanha@redhat.com>
Fri, 15 Jul 2016 09:46:54 +0000 (10:46 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 17 Jul 2016 07:59:21 +0000 (09:59 +0200)
Renames look like this with git-diff(1) when diff.renames = true is set:

  diff --git a/a b/b
  similarity index 100%
  rename from a
  rename to b

This raises the "Does not appear to be a unified-diff format patch"
error because checkpatch.pl only considers a diff valid if it contains
at least one "@@" hunk.

This patch accepts renames and copies too so that checkpatch.pl exits
successfully when a diff only renames/copies files.  The git diff
extended header format is described on the git-diff(1) man page.

Reported-by: Colin Lord <clord@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <1468576014-28788-1-git-send-email-stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
scripts/checkpatch.pl

index cf32c8f5fa32ada7c64f066908c6db368dc9e656..afa7f79f83eb704eb10ef88fb3f8eb8acf20c135 100755 (executable)
@@ -1279,6 +1279,11 @@ sub process {
                        }
                }
 
+# Accept git diff extended headers as valid patches
+               if ($line =~ /^(?:rename|copy) (?:from|to) [\w\/\.\-]+\s*$/) {
+                       $is_patch = 1;
+               }
+
 #check the patch for a signoff:
                if ($line =~ /^\s*signed-off-by:/i) {
                        # This is a signoff, if ugly, so do not double report.