🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
5 messages
5 total messages Started by Tuomas Ahola Thu, 26 Nov 2026 20:11
[PATCH v4 2/2] lint-docs: ensure command-list.txt lists all guides
#3928
Author: Tuomas Ahola
Date: Thu, 26 Nov 2026 20:11
80 lines
11866 bytes
Since 2135e1ad70 (command-list.txt: add missing 'gitcredentials' and
'gitremote-helpers', 2020-08-05) there has been a comment in
Documentation/Makefile reminding developers to add new guides also to
command-list.txt.  However, there is no linter script to enforce that.

Adapt Documentation/lint-manpages.sh to fill that role.  Extract
MAN5_TXT and MAN7_TXT from the docs Makefile and check command-list.txt
against them.  Exempt gitweb.conf(5) and gittutorial-2(7) from the
new linter routine as deliberate omissions.

Signed-off-by: Tuomas Ahola <taahol@utu.fi>
---
 Documentation/lint-manpages.sh | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

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
+	for i in "$@"
+	do
+		(
+			cat "$file"
+			cat <<EOF
 print_variable:
 	@\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
 EOF
-	) |
-	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
 
 		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)"
+MAN_GUIDES="$(extract_variable Makefile MAN5_TXT MAN7_TXT | sed -e 's/\.adoc//')"
 
 findings=$(
 	if ! check_missing_docs
-- 
ta/command-list-guides-sync-lint
Re: [PATCH v4 2/2] lint-docs: ensure command-list.txt lists all guides
#3962
Author: Tuomas Ahola
Date: Fri, 27 Nov 2026 10:33
80 lines
11931 bytes
Tuomas Ahola <taahol@utu.fi> wrote:

> Since 2135e1ad70 (command-list.txt: add missing 'gitcredentials' and
> 'gitremote-helpers', 2020-08-05) there has been a comment in
> Documentation/Makefile reminding developers to add new guides also to
> command-list.txt.  However, there is no linter script to enforce that.
> 
> Adapt Documentation/lint-manpages.sh to fill that role.  Extract
> MAN5_TXT and MAN7_TXT from the docs Makefile and check command-list.txt
> against them.  Exempt gitweb.conf(5) and gittutorial-2(7) from the
> new linter routine as deliberate omissions.
> 
> Signed-off-by: Tuomas Ahola <taahol@utu.fi>
> ---
>  Documentation/lint-manpages.sh | 29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
> 
> 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
> +	for i in "$@"
> +	do
> +		(
> +			cat "$file"
> +			cat <<EOF
>  print_variable:
>  	@\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
>  EOF

Well, that is obviously incorrect.  Sorry.  Besides, $i isn't a very eloquent
name for the iterator...

Junio, could you please squash this locally?

-----8<-----
Subject: [PATCH] fixup! lint-docs: ensure command-list.txt lists all guides

Signed-off-by: Tuomas Ahola <taahol@utu.fi>
---
 Documentation/lint-manpages.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/lint-manpages.sh b/Documentation/lint-manpages.sh
index 87a652bd22..0b123f487c 100755
--- a/Documentation/lint-manpages.sh
+++ b/Documentation/lint-manpages.sh
@@ -4,13 +4,13 @@ extract_variable () {
 	file="$1"
 	directory="$(dirname "$file")"
 	shift
-	for i in "$@"
+	for v in "$@"
 	do
 		(
 			cat "$file"
 			cat <<EOF
 print_variable:
-	@\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
+	@\$(foreach b,\$($v),echo XXX \$(b:\$X=) YYY;)
 EOF
 		) |
 		make -C "$directory" -f - print_variable 2>/dev/null |

base-commit: 0ffa3e35c7c82ab8d0de226149fb03b3f7674d05
prerequisite-patch-id: 55e8c49f2de1f1bbd117386712fd07a30f2641c7
prerequisite-patch-id: d5b07233f2f991f22c53c1a177690660f8f463ab
-- 
fixup/ta/command-list-guides-sync-lint
Re: [PATCH v4 2/2] lint-docs: ensure command-list.txt lists all guides
#3971
Author: Junio C Hamano
Date: Fri, 27 Nov 2026 15:07
150 lines
17707 bytes
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.
Re: [PATCH v4 2/2] lint-docs: ensure command-list.txt lists all guides
#3982
Author: Tuomas Ahola
Date: Fri, 27 Nov 2026 17:42
210 lines
16831 bytes
Junio C Hamano <gitster@pobox.com> wrote:

> 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.
> 

Yep.

> > +	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?
> 

Yes, I already noticed that blunder (cf. <20261127103346.vPrBT%taahol@utu.fi>)

> 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?
> 

I did all that when I first wrote that reroll.  However, my draft used 'shift'
in the loop which looked a bit funny when I revisited the patch and sent it
out.  Obviously I should have replaced $i with $i when I dropped that shift.

> 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?
> 

Hmm, I think I decided against something like that but perhaps I should
reconsider that option.

> 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?
> 

Good point.  That indeed seems to be the case.

> 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.
> 

On the other hand, having such stale entries still makes 'make check-docs'
barf:

$ rm Documentation/gittutorial-2.adoc && make check-docs
make -C Documentation lint-docs
make[1]: Entering directory '.../git-docs/Documentation'
make[1]: *** No rule to make target 'gittutorial-2.adoc', needed by '.build/lint-docs/man-section-order/gittutorial-2.ok'.  Stop.
make[1]: Leaving directory '.../git-docs/Documentation'
make: *** [Makefile:3984: check-docs] Error 2

Hmm...

> >  
> >  		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?

Huh?  I'm not sure what you mean by "this" Makefile (this is a shell script,
isn't it?)

Oh, I think I got it.  Indeed, perhaps we can invoke the script within the
Makefile with the guides fed in as command-line parameters:

diff --git a/Documentation/Makefile b/Documentation/Makefile
index b574ca2044..0ef57503a9 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -532,8 +532,8 @@ $(LINT_DOCS_DOC_STYLE): .build/lint-docs/doc-style/%.ok: %.adoc
 .PHONY: lint-docs-doc-style
 lint-docs-doc-style: $(LINT_DOCS_DOC_STYLE)
 
-lint-docs-manpages:
-	$(QUIET_GEN)./lint-manpages.sh
+lint-docs-manpages: $(MAN5_TXT) $(MAN7_TXT)
+	$(QUIET_GEN)./lint-manpages.sh $(patsubst %.adoc,%,$(MAN5_TXT) $(MAN7_TXT))
 
 .PHONY: lint-docs-meson
 lint-docs-meson:

I quite like that approach.  So, let's make it our plan for v5(?)

> 
> 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.

Thanks!
Re: [PATCH v4 2/2] lint-docs: ensure command-list.txt lists all guides
#3988
Author: Junio C Hamano
Date: Fri, 27 Nov 2026 19:13
21 lines
13296 bytes
Tuomas Ahola <taahol@utu.fi> writes:

> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index b574ca2044..0ef57503a9 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -532,8 +532,8 @@ $(LINT_DOCS_DOC_STYLE): .build/lint-docs/doc-style/%.ok: %.adoc
>  .PHONY: lint-docs-doc-style
>  lint-docs-doc-style: $(LINT_DOCS_DOC_STYLE)
>  
> -lint-docs-manpages:
> -	$(QUIET_GEN)./lint-manpages.sh
> +lint-docs-manpages: $(MAN5_TXT) $(MAN7_TXT)
> +	$(QUIET_GEN)./lint-manpages.sh $(patsubst %.adoc,%,$(MAN5_TXT) $(MAN7_TXT))

Yes, exactly.  Then extract_variable does not have to change, as it only
is used to read from the top-level Makefile.  Perhaps this patch will
shrink quite a lot.

Thanks.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads