Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdab07e8

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

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
foreachmy$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
foreachmy$source_filename (@files)
457459
{
460+
# skip duplicates
461+
nextif$processed{$source_filename};
462+
$processed{$source_filename} = 1;
463+
458464
# ignore anything that's not a .c or .h file
459465
nextunless$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)

[8]ページ先頭

©2009-2025 Movatter.jp