diff mbox series

[v3,3/4] Documentation: don't hardcode command categories twice

Message ID 552444a84241d280640c4700f17477a9c297fb73.1596590347.git.gitgitgadget@gmail.com (mailing list archive)
State Accepted
Commit e7a9807a627772f795d5105be497fd648611bc70
Headers show
Series List all guides in git(1) | expand

Commit Message

Philippe Blain via GitGitGadget Aug. 5, 2020, 1:19 a.m. UTC
From: Junio C Hamano <gitster@pobox.com>

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>
---
 Documentation/Makefile      |  2 +-
 Documentation/cmd-list.perl | 20 ++++++++------------
 2 files changed, 9 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 39f6fc8de7..eb9c7e2b0e 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -302,7 +302,7 @@  $(cmds_txt): cmd-list.made
 
 cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
 	$(QUIET_GEN)$(RM) $@ && \
-	$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
+	$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(cmds_txt) $(QUIET_STDERR) && \
 	date >$@
 
 mergetools_txt = mergetools-diff.txt mergetools-merge.txt
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
index 5aa73cfe45..ee96de53db 100755
--- a/Documentation/cmd-list.perl
+++ b/Documentation/cmd-list.perl
@@ -38,12 +38,15 @@  sub format_one {
 	}
 }
 
-while (<>) {
+my ($input, @categories) = @ARGV;
+
+open IN, "<$input";
+while (<IN>) {
 	last if /^### command list/;
 }
 
 my %cmds = ();
-for (sort <>) {
+for (sort <IN>) {
 	next if /^#/;
 
 	chomp;
@@ -51,17 +54,10 @@  sub format_one {
 	$attr = '' unless defined $attr;
 	push @{$cmds{$cat}}, [$name, " $attr "];
 }
+close IN;
 
-for my $cat (qw(ancillaryinterrogators
-		ancillarymanipulators
-		mainporcelain
-		plumbinginterrogators
-		plumbingmanipulators
-		synchingrepositories
-		foreignscminterface
-		purehelpers
-		synchelpers)) {
-	my $out = "cmds-$cat.txt";
+for my $out (@categories) {
+	my ($cat) = $out =~ /^cmds-(.*)\.txt$/;
 	open O, '>', "$out+" or die "Cannot open output file $out+";
 	for (@{$cmds{$cat}}) {
 		format_one(\*O, $_);