From: Ævar Arnfjörð Bjarmason Date: Wed, 17 Mar 2021 12:47:15 GMT Subject: Re: [PATCH 5/7] Makefile: add 'check-sort' target Message-ID: <87mtv2dk18.fsf@evledraar.gmail.com> In-Reply-To: <5088e93d76e44de9d079b7b2296b8c810828a2f5.1615856156.git.liu.denton@gmail.com> On Tue, Mar 16 2021, Denton Liu wrote: > In the previous few commits, we sorted many lists into ASCII-order. In > order to ensure that they remain that way, add the 'check-sort' target. > > The check-sort.perl program ensures that consecutive lines that match > the same regex are sorted in ASCII-order. The 'check-sort' target runs > the check-sort.perl program on some files which are known to contain > sorted lists. > > Signed-off-by: Denton Liu > --- > > Notes: > Full disclaimer: this is the first time I've written anything in Perl. > Please let me know if I'm doing anything unconventional :) > > Makefile | 25 +++++++++++++++++++++++++ > check-sort.perl | 31 +++++++++++++++++++++++++++++++ > 2 files changed, 56 insertions(+) > create mode 100755 check-sort.perl > > diff --git a/Makefile b/Makefile > index 5832aa33da..b23dff384d 100644 > --- a/Makefile > +++ b/Makefile > @@ -3240,6 +3240,31 @@ check-docs:: > check-builtins:: > ./check-builtins.sh > > +.PHONY: check-sort > +check-sort:: > + ./check-sort.perl \ > + 'ALL_COMMANDS \+=' \ > + 'ALL_COMMANDS_TO_INSTALL \+=' \ > + 'BINDIR_PROGRAMS_NEED_X \+=' \ > + 'BINDIR_PROGRAMS_NO_X \+=' \ > + 'BUILTIN_OBJS \+=' \ > + 'BUILT_INS \+=' \ > + 'FUZZ_OBJS \+=' \ > + 'GENERATED_H \+=' \ > + 'LIB_OBJS \+=' \ > + 'SCRIPT_LIB \+=' \ > + 'SCRIPT_PERL \+=' \ > + 'SCRIPT_PYTHON \+=' \ > + 'SCRIPT_SH \+=' \ > + 'TEST_BUILTINS_OBJS \+=' \ > + 'TEST_PROGRAMS_NEED_X \+=' \ > + 'THIRD_PARTY_SOURCES \+=' \ > + 'XDIFF_OBJS \+=' \ > + [...] > + ./check-sort.perl '\t\{ "[^"]*",' builtins ' +test_expect_success 'list of builtins in git.c should be sorted' ' + sort builtins >sorted && + test_cmp sorted builtins +' + while read builtin do test_expect_success "$builtin can handle -h" ' Which just leaves: > + ./check-sort.perl 'int cmd_[^(]*\(' + ./check-sort.perl 'int cmd__[^(]*\('