Skip to content

Commit 4394bb3

Browse files
committed
git.txt: add list of guides
Not all man5/man7 guides are mentioned in the 'git(1)' documentation, which makes the missing ones somewhat hard to find. Add a list of the guides to git(1) by leveraging the existing `Documentation/cmd-list.perl` script to generate a file `cmds-guide.txt` which gets included in git.txt. 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. Also, do not hard-code the manual section '1'. Instead, use a regex so that the manual section is discovered from the first line of each `git*.txt` file. This addition was hinted at in 1b81d8c (help: use command-list.txt for the source of guides, 2018-05-20). Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Philippe Blain <[email protected]>
1 parent f49cf08 commit 4394bb3

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

Documentation/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,15 @@ cmds_txt = cmds-ancillaryinterrogators.txt \
295295
cmds-plumbingmanipulators.txt \
296296
cmds-synchingrepositories.txt \
297297
cmds-synchelpers.txt \
298+
cmds-guide.txt \
298299
cmds-purehelpers.txt \
299300
cmds-foreignscminterface.txt
300301

301302
$(cmds_txt): cmd-list.made
302303

303304
cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
304305
$(QUIET_GEN)$(RM) $@ && \
305-
$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
306+
$(PERL_PATH) ./cmd-list.perl ../command-list.txt $(cmds_txt) $(QUIET_STDERR) && \
306307
date >$@
307308

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

Documentation/cmd-list.perl

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ sub format_one {
66
my ($out, $nameattr) = @_;
77
my ($name, $attr) = @$nameattr;
88
my ($state, $description);
9+
my $mansection;
910
$state = 0;
1011
open I, '<', "$name.txt" or die "No such file $name.txt";
1112
while (<I>) {
13+
if (/^git[a-z0-9-]*\(([0-9])\)$/) {
14+
$mansection = $1;
15+
next;
16+
}
1217
if (/^NAME$/) {
1318
$state = 1;
1419
next;
@@ -27,7 +32,7 @@ sub format_one {
2732
die "No description found in $name.txt";
2833
}
2934
if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
30-
print $out "linkgit:$name\[1\]::\n\t";
35+
print $out "linkgit:$name\[$mansection\]::\n\t";
3136
if ($attr =~ / deprecated /) {
3237
print $out "(deprecated) ";
3338
}
@@ -38,30 +43,26 @@ sub format_one {
3843
}
3944
}
4045

41-
while (<>) {
46+
my ($input, @categories) = @ARGV;
47+
48+
open IN, "<$input";
49+
while (<IN>) {
4250
last if /^### command list/;
4351
}
4452

4553
my %cmds = ();
46-
for (sort <>) {
54+
for (sort <IN>) {
4755
next if /^#/;
4856

4957
chomp;
5058
my ($name, $cat, $attr) = /^(\S+)\s+(.*?)(?:\s+(.*))?$/;
5159
$attr = '' unless defined $attr;
5260
push @{$cmds{$cat}}, [$name, " $attr "];
5361
}
62+
close IN;
5463

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";
64+
for my $out (@categories) {
65+
my ($cat) = $out =~ /^cmds-(.*)\.txt$/;
6566
open O, '>', "$out+" or die "Cannot open output file $out+";
6667
for (@{$cmds{$cat}}) {
6768
format_one(\*O, $_);

Documentation/git.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,13 @@ users typically do not use them directly.
304304

305305
include::cmds-purehelpers.txt[]
306306

307+
Guides
308+
------
309+
310+
The following documentation pages are guides about Git concepts.
311+
312+
include::cmds-guide.txt[]
313+
307314

308315
Configuration Mechanism
309316
-----------------------

0 commit comments

Comments
 (0)