Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dab07e8

Browse files
committed
pgindent: filter files for the --commit option
per gripe from Shi Yu, solution from Jelte Fennema Also add a check that the file exists, and issue a warning if it doesn't. As an efficiency measure, avoid processing any file more than once. Discussion: https://postgr.es/m/TYAPR01MB6315B86619944D4A6B56842DFDDE9@TYAPR01MB6315.jpnprd01.prod.outlook.com
1 parent 10a082b commit dab07e8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/tools/pgindent/pgindent

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ File::Find::find({wanted => $wanted}, @ARGV) if @ARGV;
444444
foreach my $commit (@commits)
445445
{
446446
my $prev="$commit~";
447-
my @affected=`git diff-tree --no-commit-id --name-only -r $commit $prev`;
447+
my @affected=`git diff --diff-filter=ACMR --name-only $prev $commit`;
448448
die "git error" if $?;
449449
chomp(@affected);
450450
push(@files,@affected);
@@ -453,11 +453,23 @@ foreach my $commit (@commits)
453453
# remove excluded files from the file list
454454
process_exclude();
455455

456+
my %processed;
457+
456458
foreach my $source_filename (@files)
457459
{
460+
# skip duplicates
461+
next if $processed{$source_filename};
462+
$processed{$source_filename} = 1;
463+
458464
# ignore anything that's not a .c or .h file
459465
next unless $source_filename =~ /\.[ch]$/;
460466

467+
# don't try to indent a file that doesn't exist
468+
unless (-f $source_filename)
469+
{
470+
warn "Could not find $source_filename";
471+
next;
472+
}
461473
# Automatically ignore .c and .h files that correspond to a .y or .l
462474
# file. indent tends to get badly confused by Bison/flex output,
463475
# and there's no value in indenting derived files anyway.

0 commit comments

Comments
 (0)