diff options
author | Andrew Dunstan | 2023-01-24 21:04:21 +0000 |
---|---|---|
committer | Andrew Dunstan | 2023-01-24 21:09:09 +0000 |
commit | 1249371632db9d97786edfb3d58c3e89e75b9519 (patch) | |
tree | a3bde8aca110b84ca4cd924e8ea51f1a37efeef0 | |
parent | f1358ca52dd7b8cedd29c6f2f8c163914f03ea2e (diff) |
Improve exclude pattern file processing in pgindent
This makes two small changes that will improve pgindent's usefulness in
a git hook. First, it looks for the exclude file relative to the current
directory. And second, it applies the filters to filenames given on the
command line as well as those found in a directory sweep.
It might prove necessary to make further efforts to find the exclude
file, and even to allow multiple exclude files, but for now this should
be enough for most purposes.
Reviewed by Jelte Fennema
-rwxr-xr-x | src/tools/pgindent/pgindent | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 5eff1f8032..1f95a1a34e 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -63,6 +63,10 @@ $code_base ||= '.' unless @ARGV; $excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns" if $code_base && -f "$code_base/src/tools/pgindent/exclude_file_patterns"; +# also look under the current directory for the exclude patterns file +$excludes ||= "src/tools/pgindent/exclude_file_patterns" + if -f "src/tools/pgindent/exclude_file_patterns"; + # The typedef list that's mechanically extracted by the buildfarm may omit # some names we want to treat like typedefs, e.g. "bool" (which is a macro # according to <stdbool.h>), and may include some names we don't want @@ -421,8 +425,6 @@ File::Find::find( }, $code_base) if $code_base; -process_exclude(); - $filtered_typedefs_fh = load_typedefs(); check_indent(); @@ -430,6 +432,9 @@ check_indent(); # any non-option arguments are files to be processed push(@files, @ARGV); +# the exclude list applies to command line arguments as well as found files +process_exclude(); + foreach my $source_filename (@files) { # ignore anything that's not a .c or .h file |