Skip to contentSkip to conversation

scripts: make checkpatch cleaner for renamed files

PATCH Applied David Hunt 3 participants 3 messages Feb 20, 2017 – Feb 21, 2017

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 scripts: make checkpatch cleaner for renamed files

When a file is renamed, a normal diff will include all the code of the renamed file, and checkpatch will find warnings and errors, even though it's just a rename.

This change will result in a 'rename' line in the diff, resulting in a much cleaner checkpatches result.

---
 devtools/checkpatches.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
devtools/checkpatches.sh +2 -1
index cfe262b..6fbfb50 100755
@@ -89,7 +89,8 @@ check () { # <patch> <commit> <title>
 	if [ -n "$1" ] ; then
 		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
 	elif [ -n "$2" ] ; then
-		report=$(git format-patch --no-stat --stdout -1 $commit |
+		report=$(git format-patch --find-renames \
+			--no-stat --stdout -1 $commit |
 			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	else
 		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines · David Hunt

When a file is renamed, a normal diff will include all the code of the renamed file, and checkpatch will find warnings and errors, even though it's just a rename.

This change will result in a 'rename' line in the diff, resulting in a much cleaner checkpatches result.

---
 devtools/checkpatches.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
devtools/checkpatches.sh +0 -0
index cfe262b..6fbfb50 100755

devtools/checkpatches.sh check () { # <patch> <commit> <title> · line 96

Quoted 9 lines
devtools/checkpatches.sh +2 -1
@@ -89,7 +89,8 @@ check () { # <patch> <commit> <title>
 	if [ -n "$1" ] ; then
 		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
 	elif [ -n "$2" ] ; then
-		report=$(git format-patch --no-stat --stdout -1 $commit |
+		report=$(git format-patch --find-renames \
+			--no-stat --stdout -1 $commit |
 			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	else
 		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)

This seems a good idea. Renaming legacy files which aren't checkpatch clean throws up lots of issues that we don't want to fix as part of the rename.

#2 lore raw

2017-02-20 11:16, Bruce Richardson:

Quoted 32 lines · David Hunt
Quoted 17 lines

When a file is renamed, a normal diff will include all the code of the renamed file, and checkpatch will find warnings and errors, even though it's just a rename.

This change will result in a 'rename' line in the diff, resulting in a much cleaner checkpatches result.

---
 devtools/checkpatches.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
devtools/checkpatches.sh +0 -0
index cfe262b..6fbfb50 100755

devtools/checkpatches.sh check () { # <patch> <commit> <title> · line 96

Quoted 9 lines
devtools/checkpatches.sh +2 -1
@@ -89,7 +89,8 @@ check () { # <patch> <commit> <title>
 	if [ -n "$1" ] ; then
 		report=$($DPDK_CHECKPATCH_PATH $options "$1" 2>/dev/null)
 	elif [ -n "$2" ] ; then
-		report=$(git format-patch --no-stat --stdout -1 $commit |
+		report=$(git format-patch --find-renames \
+			--no-stat --stdout -1 $commit |
 			$DPDK_CHECKPATCH_PATH $options - 2>/dev/null)
 	else
 		report=$($DPDK_CHECKPATCH_PATH $options - 2>/dev/null)

This seems a good idea. Renaming legacy files which aren't checkpatch clean throws up lots of issues that we don't want to fix as part of the rename.

Quoted 1 line

Applied, thanks