about summary refs log tree commit diff
path: root/third_party/git/Documentation/cmd-list.perl
diff options
context:
space:
mode:
authorVincent Ambo <Vincent Ambo>2020-01-11T23·36+0000
committerVincent Ambo <Vincent Ambo>2020-01-11T23·40+0000
commit7ef0d62730840ded097b524104cc0a0904591a63 (patch)
treea670f96103667aeca4789a95d94ca0dff550c4ce /third_party/git/Documentation/cmd-list.perl
parent6a2a3007077818e24a3d56fc492ada9206a10cf0 (diff)
parent1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5 (diff)
merge(third_party/git): Merge squashed git subtree at v2.23.0 r/373
Merge commit '1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5' as 'third_party/git'
Diffstat (limited to 'third_party/git/Documentation/cmd-list.perl')
-rwxr-xr-xthird_party/git/Documentation/cmd-list.perl78
1 files changed, 78 insertions, 0 deletions
diff --git a/third_party/git/Documentation/cmd-list.perl b/third_party/git/Documentation/cmd-list.perl
new file mode 100755
index 000000000000..5aa73cfe458d
--- /dev/null
+++ b/third_party/git/Documentation/cmd-list.perl
@@ -0,0 +1,78 @@
+#!/usr/bin/perl -w
+
+use File::Compare qw(compare);
+
+sub format_one {
+	my ($out, $nameattr) = @_;
+	my ($name, $attr) = @$nameattr;
+	my ($state, $description);
+	$state = 0;
+	open I, '<', "$name.txt" or die "No such file $name.txt";
+	while (<I>) {
+		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\[1\]::\n\t";
+		if ($attr =~ / deprecated /) {
+			print $out "(deprecated) ";
+		}
+		print $out "$text.\n\n";
+	}
+	else {
+		die "Description does not match $name: $description";
+	}
+}
+
+while (<>) {
+	last if /^### command list/;
+}
+
+my %cmds = ();
+for (sort <>) {
+	next if /^#/;
+
+	chomp;
+	my ($name, $cat, $attr) = /^(\S+)\s+(.*?)(?:\s+(.*))?$/;
+	$attr = '' unless defined $attr;
+	push @{$cmds{$cat}}, [$name, " $attr "];
+}
+
+for my $cat (qw(ancillaryinterrogators
+		ancillarymanipulators
+		mainporcelain
+		plumbinginterrogators
+		plumbingmanipulators
+		synchingrepositories
+		foreignscminterface
+		purehelpers
+		synchelpers)) {
+	my $out = "cmds-$cat.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";
+	}
+}