diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-17 23:07:50 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-18 09:14:52 +0100 |
commit | abe4eaf57be93300be4710aee0bc283055403f4b (patch) | |
tree | 4d758a429c060c3bcd9ee61b1e32f973d8ca4b9c /solenv | |
parent | 4a0f506f0d8c2a017f0cf880481d3c0c32a48909 (diff) |
clang-format: allow just listing formatted files
Without running clang-format on them. Also format one file at a time, so
we don't run into command line length limits as the number of formatted
files grows.
Change-Id: Ie559d566db784e04965678f056dcb81cefe95378
Reviewed-on: https://gerrit.libreoffice.org/48085
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'solenv')
-rwxr-xr-x | solenv/clang-format/reformat-formatted-files | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/solenv/clang-format/reformat-formatted-files b/solenv/clang-format/reformat-formatted-files index 5059251682d3..04b0adde8e4e 100755 --- a/solenv/clang-format/reformat-formatted-files +++ b/solenv/clang-format/reformat-formatted-files @@ -7,6 +7,7 @@ # Reformat files which are not blacklisted. This is interesting if the # clang-format version or config changes. +# -n allows just listing the formatted files. use strict; use warnings; @@ -17,6 +18,7 @@ my $clang_format = ClangFormat::find(); my $src = ClangFormat::get_extension_regex(); my $blacklist_names = ClangFormat::get_blacklist(); my @filenames = (); +my $dry_run = 0; # Get a list of files. open (FILES, "git ls-files |") || die "Cannot run git ls-files."; @@ -29,7 +31,19 @@ while (my $filename = <FILES>) } } -print("$clang_format -i " . join(" ", @filenames) . "\n"); -system("$clang_format -i " . join(" ", @filenames) . "\n"); +if ($#ARGV ge 0 && $ARGV[0] eq "-n") +{ + $dry_run = 1; +} + +foreach my $filename (@filenames) +{ + my $command = $clang_format . " -i " . $filename; + print($filename . "\n"); + if (!$dry_run) + { + system($command); + } +} # vim: set shiftwidth=4 softtabstop=4 expandtab: |