32c6fff4b8
We attribute each documentation text file to a man section by finding a line in the file that looks like "gitfoo(<digit>)". Commitcc75e556a9
("scalar: add to 'git help -a' command list", 2022-09-02) updated this logic to look not only for "gitfoo" but also "scalarfoo". In doing so, it forgot to account for the fact that after the updated regex has found a match, the man section is no longer to be found in `$1` but now lives in `$2`. This makes our git(1) manpage look as follows: Main porcelain commands git-add(git) Add file contents to the index. [...] gitk(git) The Git repository browser. scalar(scalar) A tool for managing large Git repositories. Restore the man sections by not capturing the (git|scalar) part of the match into `$1`. As noted by Ævar [1], we could even match any "foo" rather than just "gitfoo" and "scalarfoo", but that's a larger change. For now, just fix the regression incc75e556a9
. [1] https://lore.kernel.org/git/220923.86wn9u4joo.gmgdl@evledraar.gmail.com/#t Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
80 lines
1.5 KiB
Perl
Executable File
80 lines
1.5 KiB
Perl
Executable File
#!/usr/bin/perl -w
|
|
|
|
use File::Compare qw(compare);
|
|
|
|
sub format_one {
|
|
my ($out, $nameattr) = @_;
|
|
my ($name, $attr) = @$nameattr;
|
|
my ($state, $description);
|
|
my $mansection;
|
|
$state = 0;
|
|
open I, '<', "$name.txt" or die "No such file $name.txt";
|
|
while (<I>) {
|
|
if (/^(?:git|scalar)[a-z0-9-]*\(([0-9])\)$/) {
|
|
$mansection = $1;
|
|
next;
|
|
}
|
|
if (/^NAME$/) {
|
|
$state = 1;
|
|
next;
|
|
}
|
|
if ($state == 1 && /^----$/) {
|
|
$state = 2;
|
|
next;
|
|
}
|
|
next if ($state != 2);
|
|
chomp;
|
|
$description = $_;
|
|
last;
|
|
}
|
|
close I;
|
|
if (!defined $description) {
|
|
die "No description found in $name.txt";
|
|
}
|
|
if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
|
|
print $out "linkgit:$name\[$mansection\]::\n\t";
|
|
if ($attr =~ / deprecated /) {
|
|
print $out "(deprecated) ";
|
|
}
|
|
print $out "$text.\n\n";
|
|
}
|
|
else {
|
|
die "Description does not match $name: $description";
|
|
}
|
|
}
|
|
|
|
my ($input, @categories) = @ARGV;
|
|
|
|
open IN, "<$input";
|
|
while (<IN>) {
|
|
last if /^### command list/;
|
|
}
|
|
|
|
my %cmds = ();
|
|
for (sort <IN>) {
|
|
next if /^#/;
|
|
|
|
chomp;
|
|
my ($name, $cat, $attr) = /^(\S+)\s+(.*?)(?:\s+(.*))?$/;
|
|
$attr = '' unless defined $attr;
|
|
push @{$cmds{$cat}}, [$name, " $attr "];
|
|
}
|
|
close IN;
|
|
|
|
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, $_);
|
|
}
|
|
close O;
|
|
|
|
if (-f "$out" && compare("$out", "$out+") == 0) {
|
|
unlink "$out+";
|
|
}
|
|
else {
|
|
print STDERR "$out\n";
|
|
rename "$out+", "$out";
|
|
}
|
|
}
|