summaryrefslogtreecommitdiffstats
path: root/Documentation/cmd-list.perl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:47:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:47:53 +0000
commitc8bae7493d2f2910b57f13ded012e86bdcfb0532 (patch)
tree24e09d9f84dec336720cf393e156089ca2835791 /Documentation/cmd-list.perl
parentInitial commit. (diff)
downloadgit-c8bae7493d2f2910b57f13ded012e86bdcfb0532.tar.xz
git-c8bae7493d2f2910b57f13ded012e86bdcfb0532.zip
Adding upstream version 1:2.39.2.upstream/1%2.39.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'Documentation/cmd-list.perl')
-rwxr-xr-xDocumentation/cmd-list.perl79
1 files changed, 79 insertions, 0 deletions
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
new file mode 100755
index 0000000..755a110
--- /dev/null
+++ b/Documentation/cmd-list.perl
@@ -0,0 +1,79 @@
+#!/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";
+ }
+}