# [PATCH] Makefile: add QUIET_GEN to "tags" and "TAGS" targets

3 messages from 2021-03-28 to 2021-03-31. Participants: Ævar Arnfjörð Bjarmason, Junio C Hamano.
Thread: https://gitlist.dev/t/55403

## Ævar Arnfjörð Bjarmason, 2021-03-28 02:18

Subject: [PATCH] Makefile: add QUIET_GEN to "tags" and "TAGS" targets
Message-ID: <patch-1.1-afd0c18ca86-20210328T021814Z-avarab@gmail.com>
URL: https://gitlist.dev/e/patch-1.1-afd0c18ca86-20210328T021814Z-avarab%40gmail.com

```
Don't show the very verbose $(FIND_SOURCE_FILES) command on every
"make TAGS" invocation. Let's also use the "cmd >x+ && mv x+ x"
pattern here so we don't momentarily clobber the file.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Makefile | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 55c8035fa80..f317af1b602 100644
--- a/Makefile
+++ b/Makefile
@@ -2690,12 +2690,15 @@ FIND_SOURCE_FILES = ( \
 	)
 
 $(ETAGS_TARGET): FORCE
-	$(RM) $(ETAGS_TARGET)
-	$(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
+	echo $(ALL_SOURCE_FILES)
+	$(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \
+	$(FIND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \
+	mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)"
 
 tags: FORCE
-	$(RM) tags
-	$(FIND_SOURCE_FILES) | xargs ctags -a
+	$(QUIET_GEN)$(RM) tags+ && \
+	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
+	mv tags+ tags
 
 cscope:
 	$(RM) cscope*
-- 
2.31.1.442.g6c06c9fe35c


```

## Junio C Hamano, 2021-03-28 05:56

Subject: Re: [PATCH] Makefile: add QUIET_GEN to "tags" and "TAGS" targets
Message-ID: <xmqqpmzjom7n.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqpmzjom7n.fsf%40gitster.g
In-Reply-To: <patch-1.1-afd0c18ca86-20210328T021814Z-avarab@gmail.com>

```
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Don't show the very verbose $(FIND_SOURCE_FILES) command on every
> "make TAGS" invocation. Let's also use the "cmd >x+ && mv x+ x"
> pattern here so we don't momentarily clobber the file.

We do not "redirect" ctags and etags output into x+.  

	Let's use "generate into temporary and rename to the final
	after seeing the command that generated the output finished
	successfully" pattern.

Please also correct the explanation of why it is a good idea to use
the pattern in this case.  It is not about avoiding momentarily
clobbering the output.  It is to avoid leaving an incorrect output
generated by a failed command in the file with the filename that
consumers expect.

Thanks for making our Makefile a bit less noisy.  Anybody who makes
"clean" and its friends quiet will get a gold star ;-)

> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  Makefile | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 55c8035fa80..f317af1b602 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2690,12 +2690,15 @@ FIND_SOURCE_FILES = ( \
>  	)
>  
>  $(ETAGS_TARGET): FORCE
> -	$(RM) $(ETAGS_TARGET)
> -	$(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
> +	echo $(ALL_SOURCE_FILES)
> +	$(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \
> +	$(FIND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \
> +	mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)"
>  
>  tags: FORCE
> -	$(RM) tags
> -	$(FIND_SOURCE_FILES) | xargs ctags -a
> +	$(QUIET_GEN)$(RM) tags+ && \
> +	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
> +	mv tags+ tags
>  
>  cscope:
>  	$(RM) cscope*

```

## Junio C Hamano, 2021-03-31 21:20

Subject: Re: [PATCH] Makefile: add QUIET_GEN to "tags" and "TAGS" targets
Message-ID: <xmqq5z176mwd.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq5z176mwd.fsf%40gitster.g
In-Reply-To: <xmqqpmzjom7n.fsf@gitster.g>

```
Junio C Hamano <gitster@pobox.com> writes:

> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> Don't show the very verbose $(FIND_SOURCE_FILES) command on every
>> "make TAGS" invocation. Let's also use the "cmd >x+ && mv x+ x"
>> pattern here so we don't momentarily clobber the file.
>
> We do not "redirect" ctags and etags output into x+.  
>
> 	Let's use "generate into temporary and rename to the final
> 	after seeing the command that generated the output finished
> 	successfully" pattern.
>
> Please also correct the explanation of why it is a good idea to use
> the pattern in this case.  It is not about avoiding momentarily
> clobbering the output.  It is to avoid leaving an incorrect output
> generated by a failed command in the file with the filename that
> consumers expect.
>
> Thanks for making our Makefile a bit less noisy.  Anybody who makes
> "clean" and its friends quiet will get a gold star ;-)
>
>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>> ---
>>  Makefile | 11 +++++++----
>>  1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 55c8035fa80..f317af1b602 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -2690,12 +2690,15 @@ FIND_SOURCE_FILES = ( \
>>  	)
>>  
>>  $(ETAGS_TARGET): FORCE
>> -	$(RM) $(ETAGS_TARGET)
>> -	$(FIND_SOURCE_FILES) | xargs etags -a -o $(ETAGS_TARGET)
>> +	echo $(ALL_SOURCE_FILES)

This echo I presume is a debugging aid to be removed?

>> +	$(QUIET_GEN)$(RM) "$(ETAGS_TARGET)+" && \
>> +	$(FIND_SOURCE_FILES) | xargs etags -a -o "$(ETAGS_TARGET)+" && \
>> +	mv "$(ETAGS_TARGET)+" "$(ETAGS_TARGET)"
>>  
>>  tags: FORCE
>> -	$(RM) tags
>> -	$(FIND_SOURCE_FILES) | xargs ctags -a
>> +	$(QUIET_GEN)$(RM) tags+ && \
>> +	$(FIND_SOURCE_FILES) | xargs ctags -a -o tags+ && \
>> +	mv tags+ tags
>>  
>>  cscope:
>>  	$(RM) cscope*

```
