Re: [PATCH v4 1/2] Documentation: fix linkgit references
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 4, 2016, 17:28 UTC
- Message-ID
- <xmqqd1p1ivfw.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <5729DF25.7030503@ramsayjones.plus.com>
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
Show 12 quoted lines
>>> diff --git a/Documentation/git-check-ignore.txt b/Documentation/git-check-ignore.txt >>> index e94367a..9a85998 100644 >>> --- a/Documentation/git-check-ignore.txt >>> +++ b/Documentation/git-check-ignore.txt >>> @@ -112,7 +112,7 @@ EXIT STATUS >>> SEE ALSO >>> -------- >>> linkgit:gitignore[5] >>> -linkgit:gitconfig[5] >>> +linkgit:git-config[5] > > I think Junio already noted, git-config is in section 1 not 5.
Not just that, I am afraid. This came from 368aa529 (add git-check-ignore sub-command, 2013-01-06) and it added these:
+linkgit:gitignore[5] +linkgit:gitconfig[5] +linkgit:git-ls-files[5]
The last one was later corrected, but who knows what other mistakes there are?
So I used the script attached at the bottom to audit the whole thing, and the result is here.
-- >8 -- Documentation/config.txt:1497: nongit link: :git-gui[1] Documentation/config.txt:1662: nongit link: curl[1] Documentation/diff-options.txt:274: wrong section (should be 5): gitattributes[1] Documentation/git-check-ignore.txt:115: no such source: gitconfig[5] Documentation/git-filter-branch.txt:208: nongit link: rev-list[1] Documentation/git-for-each-ref.txt:182: nongit link: :git-rev-list[1] Documentation/git-notes.txt:405: wrong section (should be 1): git[7] Documentation/technical/api-credentials.txt:246: wrong section (should be 1): git-credential[7] Documentation/technical/api-credentials.txt:271: wrong section (should be 1): git-config[5] -- 8< --
I do not think there is any false positive above, so perhaps the checker script below can be used as the link checker we discussed?
-- >8 -- #!/bin/sh
git grep -l linkgit: Documentation/ |
while read path
do
perl -e '
sub report {
my ($where, $what, $error) = @_;
print "$where: $error: $what\n";
} sub grab_section {
my ($page) = @_;
open my $fh, "<", "Documentation/$page.txt";
my $firstline = <$fh>;
chomp $firstline;
close $fh;
my ($section) = ($firstline =~ /.*\((\d)\)$/);
return $section;
} while (<>) {
my $where = "$ARGV:$.";
while (s/linkgit:((.*?)\[(\d)\])//) {
my ($target, $page, $section) = ($1, $2, $3); # De-AsciiDoc
$page =~ s/{litdd}/--/g; if ($page !~ /^git/) {
report($where, $target, "nongit link");
next;
}
if (! -f "Documentation/$page.txt") {
report($where, $target, "no such source");
next;
}
$real_section = grab_section($page);
if ($real_section != $section) {
report($where, $target,
"wrong section (should be $real_section)");
next;
}
}
}
' "$path"
done