Subject: Re: [PATCH v3 06/10] t/unit-tests: convert reftable table test to use clar

From: Junio C Hamano <[email-masked]>
Date: Tue, 03 Jun 2025 12:12:35 -0700

Junio C Hamano <[email-masked]> writes:

>> diff --git a/Makefile b/Makefile
>> index 3cccc73073..0227fdb3e1 100644
>> --- a/Makefile
>> +++ b/Makefile
>> ...
>> @@ -3972,4 +3972,4 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
>>  	$(OBJCOPY) --localize-hidden $^ $@
>>  
>>  contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
>> -	$(AR) $(ARFLAGS) $@ $^
>> +	$(AR) $(ARFLAGS) $@ $^
>> \ No newline at end of file
>
> Can anybody tell, without running "make <something>", what this
> accidental and unintended change breaks?  It may be rather
> surprising ;-)

After dropping the last newline from the top-level Makefile, 

    $ make check-docs

ends like this:

    $ make check-docs
    make -C Documentation lint-docs
    make[1]: Entering directory '/home/gitster/git.git/Documentation'
        GEN lint-docs-manpages
    removed but documented: git
    removed but documented: git-add
    ...
    removed but documented: git-write-tree
    removed but documented: scalar
    removed but listed: git-add
    removed but listed: git-am
    ...
    removed but listed: git-write-tree
    removed but listed: scalar
    make[1]: *** [Makefile:504: lint-docs-manpages] Error 1
    make[1]: Leaving directory '/home/gitster/git.git/Documentation'
    make: *** [Makefile:3829: check-docs] Error 2

This is because of a cute Makefile trick used in lint-manpages
script is not written robustly enough, but that is not much less
interesting than the lesson we learn from this episode.

A more robust and traditional way to use the same Makefile trick is
to apply this patch to Documentation/lint-manpages.sh by the way.

 Documentation/lint-manpages.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git c/Documentation/lint-manpages.sh w/Documentation/lint-manpages.sh
index a0ea572382..65758a3159 100755
--- c/Documentation/lint-manpages.sh
+++ w/Documentation/lint-manpages.sh
@@ -2,11 +2,11 @@
 
 extract_variable () {
 	(
-		cat ../Makefile
 		cat <<EOF
 print_variable:
 	@\$(foreach b,\$($1),echo XXX \$(b:\$X=) YYY;)
 EOF
+		cat ../Makefile
 	) |
 	make -C .. -f - print_variable 2>/dev/null |
 	sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p'