@matheusbsbs / matheus-bagliano / commits / e7a9807a62
Fork 0

Documentation: don't hardcode command categories twice

Instead of hard-coding the list of command categories in both `Documentation/Makefile` and `Documentation/cmd-list.perl`, make the Makefile the authoritative source and tweak `cmd-list.perl` so that it receives the list of command categories as argument. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 5, 2020 at 01:19 UTC e7a9807a627772f795d5105be497fd648611bc70
2 files changed +9 -13
Documentation/Makefile
+1 -1
@@ -302,7 +302,7 @@ $(cmds_txt): cmd-list.made
302
303 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
304 $(QUIET_GEN)$(RM) $@ && \
305 - $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
305 + $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(cmds_txt) $(QUIET_STDERR) && \
306 date >$@
307
308 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
Documentation/cmd-list.perl
+8 -12
@@ -38,12 +38,15 @@ sub format_one {
38 }
39 }
40
41 -while (<>) {
41 +my ($input, @categories) = @ARGV;
42 +
43 +open IN, "<$input";
44 +while (<IN>) {
45 last if /^### command list/;
46 }
47
48 my %cmds = ();
46 -for (sort <>) {
49 +for (sort <IN>) {
50 next if /^#/;
51
52 chomp;
@@ -51,17 +54,10 @@ for (sort <>) {
54 $attr = '' unless defined $attr;
55 push @{$cmds{$cat}}, [$name, " $attr "];
56 }
57 +close IN;
58
55 -for my $cat (qw(ancillaryinterrogators
56 - ancillarymanipulators
57 - mainporcelain
58 - plumbinginterrogators
59 - plumbingmanipulators
60 - synchingrepositories
61 - foreignscminterface
62 - purehelpers
63 - synchelpers)) {
64 - my $out = "cmds-$cat.txt";
59 +for my $out (@categories) {
60 + my ($cat) = $out =~ /^cmds-(.*)\.txt$/;
61 open O, '>', "$out+" or die "Cannot open output file $out+";
62 for (@{$cmds{$cat}}) {
63 format_one(\*O, $_);