Skip to contentSkip to conversation

checkpatch: consider git extended headers valid patches

PATCH Applied Stefan Hajnoczi 4 participants 4 messages Jul 15, 2016 – Jul 18, 2016 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: consider git extended headers valid patches

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.

---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)
scripts/checkpatch.pl +5 -0
index cf32c8f..afa7f79 100755
@@ -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.
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Stefan Hajnoczi

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.

Quoted 5 lines
---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)

and especially nice since we recommend diff.renames = true in our patch submission guidelines.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
In reply to Stefan Hajnoczi
Quoted 15 lines · Stefan Hajnoczi

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.

Quoted 5 lines
---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)

There is no maintainer for checkpatch.pl, so...

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

#3 lore raw
Quoted 22 lines · Stefan Hajnoczi
Quoted 15 lines · Stefan Hajnoczi

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.

Quoted 5 lines
---
 scripts/checkpatch.pl | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 4 lines

There is no maintainer for checkpatch.pl, so...

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Actually I've sent a pull request for this patch too this morning (forgot to sent the "applied" message because at the time I applied it I was offline), but Peter bumped it.

Paolo