From: Junio C Hamano <gitster@pobox.com>
To: "Julia Evans via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Tuomas Ahola <taahol@utu.fi>,
Julia Evans <julia@jvns.ca>
Subject: Re: [PATCH v2] doc: don't require a SYNOPSIS in section 7
Date: Sun, 04 Oct 2026 06:17:27 -0700 [thread overview]
Message-ID: <xmqqece5vc48.fsf@gitster.g> (raw)
In-Reply-To: <pull.2246.v2.git.1791033057232.gitgitgadget@gmail.com> (Julia Evans via GitGitGadget's message of "Sat, 03 Oct 2026 13:10:57 +0000")
"Julia Evans via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Changes in v2: Tuomas rewrote the Perl script changes to be both more
> declarative and and more correct. Previously it didn't work if there
> were multiple files passed on the command line.
> diff --git a/Documentation/lint-man-section-order.perl b/Documentation/lint-man-section-order.perl
> index 02408a0062..160c65e1be 100755
> --- a/Documentation/lint-man-section-order.perl
> +++ b/Documentation/lint-man-section-order.perl
> @@ -13,6 +13,9 @@ my %SECTIONS;
> },
> 'SYNOPSIS' => {
> required => 1,
> + optional_in_man_sections => {
> + '7' => 1,
> + },
> order => $order++,
> },
> 'DESCRIPTION' => {
> @@ -53,10 +56,18 @@ sub report {
> $exit_code = 1;
> }
>
> +my $man_section_number;
> my $last_was_section;
> my @actual_order;
> while (my $line = <>) {
> chomp $line;
> +
> + if ($. == 1) {
OK, this, together with the explicit "close ARGV" later in
postcontext upon seeing eof, lets us do a "special" thing on the
first line.
I think for the purpose of "doc lint", this implementation is good
enough, especially with documented "assumption".
If we wanted to shoot for a bit more robustness, on the other hand,
we would want to handle when $1 is left undef ...
> + # assume the first line is formatted like 'gitglossary(7)'
> + $line =~ m/\((\d)\)/;
> + $man_section_number = $1;
... here. Perhaps like
$man_section_number = ($line =~ /\((\d)\)/) ? $1 : "0";
If we left $man_section_number undef, ...
> if ($line =~ $SECTION_RX) {
> push @actual_order => $line;
> $last_was_section = 1;
> @@ -92,7 +103,9 @@ while (my $line = <>) {
> @actual_sections{@actual_order} = ();
>
> for my $section (sort keys %SECTIONS) {
> - next if !$SECTIONS{$section}->{required} or exists $actual_sections{$section};
> + next if !$SECTIONS{$section}->{required} or
> + $SECTIONS{$section}->{optional_in_man_sections}->{$man_section_number} or
... this will access
$SECTIONS{$section}->{optional_in_man_sections}->{undef}
and may trigger a warning on use of uninitialized value.
Also, this would autovivify $SECTIONS{*}{optional_in_man_sections}
for sections that don't have optional_in_man_sections hash (like
NAME and DESCRIPTION), which may be harmless but needless.
next prev parent reply other threads:[~2026-10-04 13:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 16:07 [PATCH] doc: don't require a SYNOPSIS in section 7 Julia Evans via GitGitGadget
2026-10-02 17:33 ` Junio C Hamano
2026-10-02 18:03 ` Junio C Hamano
2026-10-02 18:10 ` Julia Evans
2026-10-02 18:20 ` Julia Evans
2026-10-02 21:34 ` Junio C Hamano
2026-10-03 7:33 ` Tuomas Ahola
2026-10-03 11:37 ` Julia Evans
2026-10-03 12:55 ` Tuomas Ahola
2026-10-03 13:10 ` [PATCH v2] " Julia Evans via GitGitGadget
2026-10-04 13:17 ` Junio C Hamano [this message]
2026-10-06 11:17 ` Julia Evans
2026-10-06 16:07 ` Junio C Hamano
2026-10-06 16:54 ` [PATCH v3] " Julia Evans via GitGitGadget
2026-10-06 20:40 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqece5vc48.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=julia@jvns.ca \
--cc=taahol@utu.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox