aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-07-08 19:00:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:25 -0400
commitc707a81de71a27a499fde60fbb963f60602c1a94 (patch)
tree38f6a128f256ba3d2e95b470e83d8ac88c60b2cb /scripts
parentdcb6b45254e2281b6f99ea7f2d51343954aa3ba8 (diff)
checkpatch: make the CamelCase cache work for non-git trees too
Might as well check include timestamps and cache the include file CamelCase uses for the non-git case too. The camelcase cache file is now named: for git: .checkpatch-camelcase.git.<commit_id> for non-git: .checkpatch-camelcase.date.<YYYYMMDDhhmm> All .checkpatch-camelcase* files are deleted if not current. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl54
1 files changed, 35 insertions, 19 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6afcd1239ca5..2ee9eb750560 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6,6 +6,7 @@
6# Licensed under the terms of the GNU GPL License version 2 6# Licensed under the terms of the GNU GPL License version 2
7 7
8use strict; 8use strict;
9use POSIX;
9 10
10my $P = $0; 11my $P = $0;
11$P =~ s@.*/@@g; 12$P =~ s@.*/@@g;
@@ -399,37 +400,52 @@ sub seed_camelcase_includes {
399 return if ($camelcase_seeded); 400 return if ($camelcase_seeded);
400 401
401 my $files; 402 my $files;
402 my $camelcase_git_file = ""; 403 my $camelcase_cache = "";
404 my @include_files = ();
405
406 $camelcase_seeded = 1;
403 407
404 if (-d ".git") { 408 if (-d ".git") {
405 my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`; 409 my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
406 chomp $git_last_include_commit; 410 chomp $git_last_include_commit;
407 $camelcase_git_file = ".checkpatch-camelcase.$git_last_include_commit"; 411 $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
408 if (-f $camelcase_git_file) {
409 open(my $camelcase_file, '<', "$camelcase_git_file")
410 or warn "$P: Can't read '$camelcase_git_file' $!\n";
411 while (<$camelcase_file>) {
412 chomp;
413 $camelcase{$_} = 1;
414 }
415 close($camelcase_file);
416
417 return;
418 }
419 $files = `git ls-files include`;
420 } else { 412 } else {
413 my $last_mod_date = 0;
421 $files = `find $root/include -name "*.h"`; 414 $files = `find $root/include -name "*.h"`;
415 @include_files = split('\n', $files);
416 foreach my $file (@include_files) {
417 my $date = POSIX::strftime("%Y%m%d%H%M",
418 localtime((stat $file)[9]));
419 $last_mod_date = $date if ($last_mod_date < $date);
420 }
421 $camelcase_cache = ".checkpatch-camelcase.date.$last_mod_date";
422 }
423
424 if ($camelcase_cache ne "" && -f $camelcase_cache) {
425 open(my $camelcase_file, '<', "$camelcase_cache")
426 or warn "$P: Can't read '$camelcase_cache' $!\n";
427 while (<$camelcase_file>) {
428 chomp;
429 $camelcase{$_} = 1;
430 }
431 close($camelcase_file);
432
433 return;
434 }
435
436 if (-d ".git") {
437 $files = `git ls-files "include/*.h"`;
438 @include_files = split('\n', $files);
422 } 439 }
423 my @include_files = split('\n', $files); 440
424 foreach my $file (@include_files) { 441 foreach my $file (@include_files) {
425 seed_camelcase_file($file); 442 seed_camelcase_file($file);
426 } 443 }
427 $camelcase_seeded = 1;
428 444
429 if ($camelcase_git_file ne "") { 445 if ($camelcase_cache ne "") {
430 unlink glob ".checkpatch-camelcase.*"; 446 unlink glob ".checkpatch-camelcase.*";
431 open(my $camelcase_file, '>', "$camelcase_git_file") 447 open(my $camelcase_file, '>', "$camelcase_cache")
432 or warn "$P: Can't write '$camelcase_git_file' $!\n"; 448 or warn "$P: Can't write '$camelcase_cache' $!\n";
433 foreach (sort { lc($a) cmp lc($b) } keys(%camelcase)) { 449 foreach (sort { lc($a) cmp lc($b) } keys(%camelcase)) {
434 print $camelcase_file ("$_\n"); 450 print $camelcase_file ("$_\n");
435 } 451 }