From: Junio C Hamano <gitster@pobox.com>
To: Tuomas Ahola <taahol@utu.fi>
Cc: <git@vger.kernel.org>, Julia Evans <julia@jvns.ca>
Subject: Re: [PATCH v4 2/2] lint-docs: ensure command-list.txt lists all guides
Date: Fri, 27 Nov 2026 07:07:38 -0800 [thread overview]
Message-ID: <xmqqy0aecnyd.fsf@gitster.g> (raw)
In-Reply-To: <20261126201110.9046-3-taahol@utu.fi> (Tuomas Ahola's message of "Thu, 26 Nov 2026 22:11:10 +0200")
Tuomas Ahola <taahol@utu.fi> writes:
> diff --git a/Documentation/lint-manpages.sh b/Documentation/lint-manpages.sh
> index a0ea572382..87a652bd22 100755
> --- a/Documentation/lint-manpages.sh
> +++ b/Documentation/lint-manpages.sh
> @@ -1,21 +1,27 @@
> #!/bin/sh
>
> extract_variable () {
> - (
> - cat ../Makefile
> - cat <<EOF
> + file="$1"
> + directory="$(dirname "$file")"
> + shift
The first argument to the function becomes $file and then is used to
compute $directory; and we shift it out and loop over the remaining
arguments.
> + for i in "$@"
> + do
> + (
> + cat "$file"
> + cat <<EOF
> print_variable:
> @\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
> EOF
The fact that this patch does not touch these three lines gives a strong
smell, especially the reference to "$1", which was part of a single
addition to the target Makefile to ask what value an arbitrary single
variable has, dating back to 2dd100c513 (Makefile: extract script to
lint missing/extraneous manpages, 2024-06-06). Now that you are looping
over a list of variable names in "$@" using "for i in ...", shouldn't it
refer to "$i" instead?
Because 'for i in "$@"' does not alter the positional parameters, "$1"
inside the heredoc stays bound to the first variable name on every
iteration. When the script later runs
MAN_GUIDES="$(extract_variable Makefile MAN5_TXT MAN7_TXT |
sed -e 's/\.adoc//')"
extract_variable() invokes make twice with $(MAN5_TXT) both times
and never evaluates $(MAN7_TXT). None of the section 7 guides
(including gitpacking and gittutorial-2) are ever visited by
check_missing_docs() because of this, I suspect. Have you tried
introducing discrepancies to section 7 entries and seeing if your
version detects them?
Even better, instead of running make multiple times, use something like
this (warning: totally untested)
vars="$*"
(
cat "$file"
sed -e "s/^|//" <<-EOF
|print_variable:
| @\$(foreach b,\$(foreach v,$vars,\$(\$(v))),echo XXX \$(b:\$X=) YYY;)
EOF
) |
make -C "$directory" -f - print_variable 2>/dev/null |
sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p
perhaps?
Unlike "make -f -" that feeds the top-level Makefile,
Documentation/Makefile has a conditional include of "doc.dep" unless we
are running "make clean". And doc.dep has a rule that depends on
$(docdep_prereqs), which includes cmd-list.made.
Does that mean running lint-manpages.sh in a clean tree causes us to
build doc.dep while it attempts to extract MAN5_TXT and MAN7_TXT and/or
fails the build altogether (we cannot see, due to "2>/dev/null" in the
above script, the error message)? Have you tried?
It might be less error-prone than the above gymnastics to add a new
print-guides target to Documentation/Makefile, next to where it defines
the print-man1 target, imitating how the print-man1 target does its
thing.
> - ) |
> - make -C .. -f - print_variable 2>/dev/null |
> - sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
> + ) |
> + make -C "$directory" -f - print_variable 2>/dev/null |
> + sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'
> + done
> }
>
> check_missing_docs () (
> ret=0
>
> - for v in $ALL_COMMANDS
> + for v in $ALL_COMMANDS $MAN_GUIDES
> do
> case "$v" in
> git-merge-octopus) continue;;
> @@ -29,6 +35,8 @@ check_missing_docs () (
> git-stage) continue;;
> git-legacy-*) continue;;
> git-?*--?* ) continue ;;
> + gittutorial-2) continue ;;
> + gitweb.conf) continue ;;
> esac
Placing gittutorial-2 and gitweb.conf in the top case statement
skips the "test -f $v.adoc" check as well as the command-list.txt
lookup.
Moving those two arms down into the inner 'case "$v" in git) ...'
block would exempt them from command-list.txt while still catching a
stale entry in MAN5_TXT or MAN7_TXT whose '.adoc' file disappeared.
I do not know which is more appropriate for these two entries.
>
> if ! test -f "$v.adoc"
> @@ -84,9 +92,10 @@ check_extraneous_docs () {
> )
> }
>
> -BUILT_INS="$(extract_variable BUILT_INS)"
> -ALL_COMMANDS="$(extract_variable ALL_COMMANDS)"
> -EXCLUDED_PROGRAMS="$(extract_variable EXCLUDED_PROGRAMS)"
> +BUILT_INS="$(extract_variable ../Makefile BUILT_INS)"
> +ALL_COMMANDS="$(extract_variable ../Makefile ALL_COMMANDS)"
> +EXCLUDED_PROGRAMS="$(extract_variable ../Makefile EXCLUDED_PROGRAMS)"
Note that all three above read variables from somebody else; running
an extra "make" process might be warranted. But ...
> +MAN_GUIDES="$(extract_variable Makefile MAN5_TXT MAN7_TXT | sed -e 's/\.adoc//')"
... here, you are asking for the values of variables that are defined in
*this* Makefile. Why can't you inspect $(MAN5_TXT) and $(MAN7_TXT)
yourself, e.g.,
MAN_GUIDES=$(patsubst %.adoc,%,$(MAN5_TXT) $(MAN7_TXT))
or something?
It might mean that almost all the things I discussed in this review,
including all the changes to the extract_variable() procedure or the
addition of the print-guides target, were unnecessary. It is great
if we have to worry about fewer things going wrong ;-).
Thanks.
next prev parent reply other threads:[~2026-11-27 15:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 5:24 [PATCH 0/2] guides: keep Documentation/Makefile and command-list.txt in sync Tuomas Ahola
2026-09-09 5:25 ` [PATCH 1/2] command-list: add gitformat-loose(5) and gitpacking(7) Tuomas Ahola
2026-09-09 18:15 ` Junio C Hamano
2026-09-09 5:25 ` [PATCH 2/2] lint-docs: check the guide list in command-list.txt Tuomas Ahola
2026-09-09 18:15 ` Junio C Hamano
2026-09-10 19:43 ` [PATCH v2 0/2] guides: keep Documentation/Makefile and command-list.txt in sync Tuomas Ahola
2026-09-10 19:43 ` [PATCH v2 1/2] command-list.txt: add gitformat-loose(5) and gitpacking(7) Tuomas Ahola
2026-09-10 19:43 ` [PATCH v2 2/2] lint-docs: check the guide list in command-list.txt Tuomas Ahola
2026-10-29 18:48 ` [PATCH v3 0/2] guides: keep Documentation/Makefile and command-list.txt in sync Tuomas Ahola
2026-10-29 18:48 ` [PATCH v3 1/2] command-list.txt: add gitformat-loose(5) and gitpacking(7) Tuomas Ahola
2026-11-05 19:32 ` Junio C Hamano
2026-11-11 21:57 ` Tuomas Ahola
2026-10-29 18:48 ` [PATCH v3 2/2] lint-docs: check the guide list in command-list.txt Tuomas Ahola
2026-11-02 18:39 ` Julia Evans
2026-11-03 17:09 ` Tuomas Ahola
2026-11-05 19:41 ` Junio C Hamano
2026-11-11 22:00 ` Tuomas Ahola
2026-11-26 20:11 ` [PATCH v4 0/2] guides: keep Documentation/Makefile and command-list.txt in sync Tuomas Ahola
2026-11-26 20:11 ` [PATCH v4 1/2] command-list.txt: add gitformat-loose(5) and gitpacking(7) Tuomas Ahola
2026-11-27 14:17 ` Junio C Hamano
2026-11-27 21:02 ` Kristoffer Haugsbakk
2026-11-27 22:14 ` Junio C Hamano
2026-11-26 20:11 ` [PATCH v4 2/2] lint-docs: ensure command-list.txt lists all guides Tuomas Ahola
2026-11-27 10:33 ` Tuomas Ahola
2026-11-27 15:07 ` Junio C Hamano [this message]
2026-11-27 17:42 ` Tuomas Ahola
2026-11-27 19:13 ` Junio C Hamano
2026-11-30 16:22 ` [PATCH v5 0/2] guides: keep Documentation/Makefile and command-list.txt in sync Tuomas Ahola
2026-11-30 16:22 ` [PATCH v5 1/2] command-list.txt: add gitformat-loose(5) and gitpacking(7) Tuomas Ahola
2026-11-30 16:22 ` [PATCH v5 2/2] lint-docs: ensure command-list.txt lists all guides Tuomas Ahola
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=xmqqy0aecnyd.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--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