'range(n_patches, 0, -1)' generates list starting from 'n_patches'
and not including zero. This leads to checking of N most recent
commits starting from the second one.

New version will generate right list starting from 'n_patches - 1'
and including zero. So, the most recent commit (HEAD~0) will be
checked and desired behavior will be achieved.

Also, 'reversed' looks better than 'range(n_patches - 1, -1, -1)'

Fixes: a1fccabce2cb ("checkpatch: Support checking recent commits in the 
current repo.")
Signed-off-by: Ilya Maximets <[email protected]>
---
 utilities/checkpatch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 243a430..b45a255 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -480,7 +480,7 @@ if __name__ == '__main__':
 
     if n_patches:
         status = 0
-        for i in range(n_patches, 0, -1):
+        for i in reversed(range(0, n_patches)):
             revision = 'HEAD~%d' % i
             f = os.popen('git format-patch -1 --stdout %s' % revision, 'r')
             patch = f.read()
-- 
2.7.4

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to