From 936fb5af395dbbc5fca56ac3a2eaae8216992159 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Thu, 14 Dec 2023 10:39:32 -0600 Subject: [PATCH v2 3/3] Allow --check and --diff to passed in the same pgindent command This means to print the diff and exit if a diff exists. --- src/tools/pgindent/pgindent | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 067b77be54..f69923fb00 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -40,9 +40,6 @@ GetOptions(%options) || usage("bad command line argument"); usage() if $help; -usage("Cannot have both --check and --diff") - if $check && $diff; - usage("Cannot use --commit with command line file list") if (@commits && @ARGV); @@ -417,22 +414,21 @@ foreach my $source_filename (@files) if ($source ne $orig_source) { - if ($check) - { - print diff($source, $source_filename); - exit 2; - } - elsif ($check) + if (!$show_diff && !$check) { - exit 2; - } - elsif ($diff) - { - print diff($source, $source_filename); + write_source($source, $source_filename); } else { - write_source($source, $source_filename); + if ($show_diff) + { + print diff($source, $source_filename); + } + + if ($check) + { + exit 2; + } } } } -- Tristan Partin Neon (https://neon.tech)