diff mbox

[ovs-dev,4/4] checkpatch: Print commit hashes and names.

Message ID 1500029844-846-5-git-send-email-i.maximets@samsung.com
State Accepted
Headers show

Commit Message

Ilya Maximets July 14, 2017, 10:57 a.m. UTC
It's better to see real commits instead of 'HEAD~n'.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 utilities/checkpatch.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Aaron Conole July 17, 2017, 6:50 p.m. UTC | #1
Ilya Maximets <i.maximets@samsung.com> writes:

> It's better to see real commits instead of 'HEAD~n'.
>
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>
Russell Bryant July 26, 2017, 8:45 p.m. UTC | #2
On Fri, Jul 14, 2017 at 6:57 AM, Ilya Maximets <i.maximets@samsung.com> wrote:
> It's better to see real commits instead of 'HEAD~n'.
>
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
>  utilities/checkpatch.py | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)

Thanks for the patches!  I applied all 4 to master.

>
> diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
> index 7ccec51..f61b8b7 100755
> --- a/utilities/checkpatch.py
> +++ b/utilities/checkpatch.py
> @@ -500,13 +500,19 @@ if __name__ == '__main__':
>
>      if n_patches:
>          status = 0
> +
> +        git_log = 'git log --no-color --no-merges --pretty=format:"%H %s" '
> +        f = os.popen(git_log + '-%d' % n_patches, 'r')
> +        commits = f.read().split("\n")
> +        f.close()
> +

I slightly modified this to be:

@@ -502,9 +502,8 @@ if __name__ == '__main__':
         status = 0

         git_log = 'git log --no-color --no-merges --pretty=format:"%H %s" '
-        f = os.popen(git_log + '-%d' % n_patches, 'r')
-        commits = f.read().split("\n")
-        f.close()
+        with os.popen(git_log + '-%d' % n_patches, 'r') as f:
+            commits = f.read().split("\n")

         for i in reversed(range(0, n_patches)):
             revision, name = commits[i].split(" ", 1)
diff mbox

Patch

diff --git a/utilities/checkpatch.py b/utilities/checkpatch.py
index 7ccec51..f61b8b7 100755
--- a/utilities/checkpatch.py
+++ b/utilities/checkpatch.py
@@ -500,13 +500,19 @@  if __name__ == '__main__':
 
     if n_patches:
         status = 0
+
+        git_log = 'git log --no-color --no-merges --pretty=format:"%H %s" '
+        f = os.popen(git_log + '-%d' % n_patches, 'r')
+        commits = f.read().split("\n")
+        f.close()
+
         for i in reversed(range(0, n_patches)):
-            revision = 'HEAD~%d' % i
+            revision, name = commits[i].split(" ", 1)
             f = os.popen('git format-patch -1 --stdout %s' % revision, 'r')
             patch = f.read()
             f.close()
 
-            print('== Checking %s ==' % revision)
+            print('== Checking %s ("%s") ==' % (revision[0:12], name))
             result = ovs_checkpatch_parse(patch, revision)
             ovs_checkpatch_print_result(result)
             if result: