Makefile: remove mandatory "spatch" arguments from SPATCH_FLAGS

The "--patch ." part of SPATCH_FLAGS added in f57d11728d1 (coccinelle: put sane filenames into output patches, 2018-07-23) should have been added unconditionally to the "spatch" invocation instead, using it isn't optional. Let's also move the other mandatory flag to come after $(SPATCH_FLAGS), to ensure that our "--sp-file" overrides any provided in the environment, both --sp-file <arg> and --patch <arg> are last-option-wins as far as spatch(1) option parsing is concerned. The environment variable override was initially added in a9a884aea57 (coccicheck: use --all-includes by default, 2016-09-30). In practice there's probably nobody that's using SPATCH_FLAGS to try to intentionally break our invocations, but since we're changing this let's make it clear what (if anything) we expect to be overridden by user-supplied flags. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jul 5, 2022 at 15:46 UTC 7b63ea57500c352c668b4fc1af97dbc5c28b5a40
1 file changed +3 -2
Makefile
+3 -2
@@ -1286,7 +1286,7 @@ SANITIZE_ADDRESS =
1286 # For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
1287 # usually result in less CPU usage at the cost of higher peak memory.
1288 # Setting it to 0 will feed all files in a single spatch invocation.
1289 -SPATCH_FLAGS = --all-includes --patch .
1289 +SPATCH_FLAGS = --all-includes
1290 SPATCH_BATCH_SIZE = 1
1291
1292 include config.mak.uname
@@ -3131,7 +3131,8 @@ check: $(GENERATED_H)
3131 limit='-n $(SPATCH_BATCH_SIZE)'; \
3132 fi; \
3133 if ! echo $(COCCI_SOURCES) | xargs $$limit \
3134 - $(SPATCH) --sp-file $< $(SPATCH_FLAGS) \
3134 + $(SPATCH) $(SPATCH_FLAGS) \
3135 + --sp-file $< --patch . \
3136 >$@+ 2>$@.log; \
3137 then \
3138 cat $@.log; \