Skip to content

Commit e7a9807

Browse files
committed
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0371a76 commit e7a9807

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

Documentation/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ $(cmds_txt): cmd-list.made
302302

303303
cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
304304
$(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) && \
306306
date >$@
307307

308308
mergetools_txt = mergetools-diff.txt mergetools-merge.txt

Documentation/cmd-list.perl

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,26 @@ sub format_one {
3838
}
3939
}
4040

41-
while (<>) {
41+
my ($input, @categories) = @ARGV;
42+
43+
open IN, "<$input";
44+
while (<IN>) {
4245
last if /^### command list/;
4346
}
4447

4548
my %cmds = ();
46-
for (sort <>) {
49+
for (sort <IN>) {
4750
next if /^#/;
4851

4952
chomp;
5053
my ($name, $cat, $attr) = /^(\S+)\s+(.*?)(?:\s+(.*))?$/;
5154
$attr = '' unless defined $attr;
5255
push @{$cmds{$cat}}, [$name, " $attr "];
5356
}
57+
close IN;
5458

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$/;
6561
open O, '>', "$out+" or die "Cannot open output file $out+";
6662
for (@{$cmds{$cat}}) {
6763
format_one(\*O, $_);

0 commit comments

Comments
 (0)