qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 05/54] checkpatch: improve handling of multiple patch


From: Paolo Bonzini
Subject: [Qemu-devel] [PULL 05/54] checkpatch: improve handling of multiple patches or files
Date: Wed, 12 Dec 2018 16:22:26 +0100

Similar to how patchew output looks like for multiple patches,
say what file or patch is being tested _before_ emitting errors.
This is clearer to a human that scans the output from top to
bottom.

In addition, provide a truncated commit hash and subject instead of
the full hash, and process the commits first-to-last rather than
last-to-first.

Inspired by Linux commit 0dea9f1eef86bedacad91b6f652ca1ab0d08854c
("checkpatch: reduce number of `git log` calls with --git", 2016-03-20).

Signed-off-by: Paolo Bonzini <address@hidden>
---
 scripts/checkpatch.pl | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 506aa6c..2edb4e2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -340,13 +340,18 @@ my @lines = ();
 my $vname;
 if ($chk_branch) {
        my @patches;
+       my %git_commits = ();
        my $HASH;
-       open($HASH, "-|", "git", "log", "--format=%H", $ARGV[0]) ||
-               die "$P: git log --format=%H $ARGV[0] failed - $!\n";
-
-       while (<$HASH>) {
-               chomp;
-               push @patches, $_;
+       open($HASH, "-|", "git", "log", "--reverse", "--no-merges", 
"--format=%H %s", $ARGV[0]) ||
+               die "$P: git log --reverse --no-merges --format='%H %s' 
$ARGV[0] failed - $!\n";
+
+       for my $line (<$HASH>) {
+               $line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
+               next if (!defined($1) || !defined($2));
+               my $sha1 = $1;
+               my $subject = $2;
+               push(@patches, $sha1);
+               $git_commits{$sha1} = $subject;
        }
 
        close $HASH;
@@ -354,21 +359,31 @@ if ($chk_branch) {
        die "$P: no revisions returned for revlist '$chk_branch'\n"
            unless @patches;
 
+       my $i = 1;
+       my $num_patches = @patches;
        for my $hash (@patches) {
                my $FILE;
                open($FILE, '-|', "git", "show", $hash) ||
                        die "$P: git show $hash - $!\n";
-               $vname = $hash;
                while (<$FILE>) {
                        chomp;
                        push(@rawlines, $_);
                }
                close($FILE);
+               $vname = substr($hash, 0, 12) . ' (' . $git_commits{$hash} . 
')';
+               if ($num_patches > 1 && $quiet == 0) {
+                       print "$i/$num_patches Checking commit $vname\n";
+                       $vname = "Patch $i/$num_patches";
+               } else {
+                       $vname = "Commit " . $vname;
+               }
                if (!process($hash)) {
                        $exit = 1;
+                       print "\n" if ($num_patches > 1 && $quiet == 0);
                }
                @rawlines = ();
                @lines = ();
+               $i++;
        }
 } else {
        for my $filename (@ARGV) {
@@ -387,6 +402,7 @@ if ($chk_branch) {
                } else {
                        $vname = $filename;
                }
+               print "Checking $filename...\n" if @ARGV > 1 && $quiet == 0;
                while (<$FILE>) {
                        chomp;
                        push(@rawlines, $_);
-- 
1.8.3.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]