Skip to content

Commit 1249371

Browse files
committed
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
1 parent f1358ca commit 1249371

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/tools/pgindent/pgindent

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ $code_base ||= '.' unless @ARGV;
6363
$excludes ||= "$code_base/src/tools/pgindent/exclude_file_patterns"
6464
if $code_base && -f "$code_base/src/tools/pgindent/exclude_file_patterns";
6565

66+
# also look under the current directory for the exclude patterns file
67+
$excludes ||= "src/tools/pgindent/exclude_file_patterns"
68+
if -f "src/tools/pgindent/exclude_file_patterns";
69+
6670
# The typedef list that's mechanically extracted by the buildfarm may omit
6771
# some names we want to treat like typedefs, e.g. "bool" (which is a macro
6872
# according to <stdbool.h>), and may include some names we don't want
@@ -421,15 +425,16 @@ File::Find::find(
421425
},
422426
$code_base) if $code_base;
423427

424-
process_exclude();
425-
426428
$filtered_typedefs_fh = load_typedefs();
427429

428430
check_indent();
429431

430432
# any non-option arguments are files to be processed
431433
push(@files, @ARGV);
432434

435+
# the exclude list applies to command line arguments as well as found files
436+
process_exclude();
437+
433438
foreach my $source_filename (@files)
434439
{
435440
# ignore anything that's not a .c or .h file

0 commit comments

Comments
 (0)