checkpatch: improve handling of multiple patches or files
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 <pbonzini@redhat.com>
This commit is contained in:
parent
fd9c0cfeb7
commit
c182b61996
@ -339,13 +339,18 @@ my @lines = ();
|
|||||||
my $vname;
|
my $vname;
|
||||||
if ($chk_branch) {
|
if ($chk_branch) {
|
||||||
my @patches;
|
my @patches;
|
||||||
|
my %git_commits = ();
|
||||||
my $HASH;
|
my $HASH;
|
||||||
open($HASH, "-|", "git", "log", "--format=%H", $ARGV[0]) ||
|
open($HASH, "-|", "git", "log", "--reverse", "--no-merges", "--format=%H %s", $ARGV[0]) ||
|
||||||
die "$P: git log --format=%H $ARGV[0] failed - $!\n";
|
die "$P: git log --reverse --no-merges --format='%H %s' $ARGV[0] failed - $!\n";
|
||||||
|
|
||||||
while (<$HASH>) {
|
for my $line (<$HASH>) {
|
||||||
chomp;
|
$line =~ /^([0-9a-fA-F]{40,40}) (.*)$/;
|
||||||
push @patches, $_;
|
next if (!defined($1) || !defined($2));
|
||||||
|
my $sha1 = $1;
|
||||||
|
my $subject = $2;
|
||||||
|
push(@patches, $sha1);
|
||||||
|
$git_commits{$sha1} = $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
close $HASH;
|
close $HASH;
|
||||||
@ -353,21 +358,31 @@ if ($chk_branch) {
|
|||||||
die "$P: no revisions returned for revlist '$chk_branch'\n"
|
die "$P: no revisions returned for revlist '$chk_branch'\n"
|
||||||
unless @patches;
|
unless @patches;
|
||||||
|
|
||||||
|
my $i = 1;
|
||||||
|
my $num_patches = @patches;
|
||||||
for my $hash (@patches) {
|
for my $hash (@patches) {
|
||||||
my $FILE;
|
my $FILE;
|
||||||
open($FILE, '-|', "git", "show", $hash) ||
|
open($FILE, '-|', "git", "show", $hash) ||
|
||||||
die "$P: git show $hash - $!\n";
|
die "$P: git show $hash - $!\n";
|
||||||
$vname = $hash;
|
|
||||||
while (<$FILE>) {
|
while (<$FILE>) {
|
||||||
chomp;
|
chomp;
|
||||||
push(@rawlines, $_);
|
push(@rawlines, $_);
|
||||||
}
|
}
|
||||||
close($FILE);
|
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)) {
|
if (!process($hash)) {
|
||||||
$exit = 1;
|
$exit = 1;
|
||||||
|
print "\n" if ($num_patches > 1 && $quiet == 0);
|
||||||
}
|
}
|
||||||
@rawlines = ();
|
@rawlines = ();
|
||||||
@lines = ();
|
@lines = ();
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for my $filename (@ARGV) {
|
for my $filename (@ARGV) {
|
||||||
@ -386,6 +401,7 @@ if ($chk_branch) {
|
|||||||
} else {
|
} else {
|
||||||
$vname = $filename;
|
$vname = $filename;
|
||||||
}
|
}
|
||||||
|
print "Checking $filename...\n" if @ARGV > 1 && $quiet == 0;
|
||||||
while (<$FILE>) {
|
while (<$FILE>) {
|
||||||
chomp;
|
chomp;
|
||||||
push(@rawlines, $_);
|
push(@rawlines, $_);
|
||||||
|
Loading…
Reference in New Issue
Block a user