Subject: [PATCH] Makefile: dedup git-ls-files output to prevent duplicate targets

From: Jiang Xin <[email-masked]>
Date: Thu, 26 May 2022 10:15:40 +0800

From: Jiang Xin <[email-masked]>

If there are unresolved conflicts left in the working tree, "make" may
report warnings as follows:

    Makefile:xxxx: target '.build/pot/po/FOO.c.po' given more than once
                   in the same rule

The duplicate targets are introduced by the following pattern rule we
added in the preceding commit for incremental build of "po/git.pot",

    $(LOCALIZED_C_GEN_PO): .build/pot/po/%.po: %

and the duplicate entries in $(LOCALIZED_C_GEN_PO) come from the
"git ls-files" command in SOURCES_CMD.

We can pass the option "--deduplicate" to git-ls-files to suppress
duplicate entries for unresolved conflicts.

Reported-by: Junio C Hamano <[email-masked]>
Signed-off-by: Jiang Xin <[email-masked]>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index a3f8446de9..a8880ed482 100644
--- a/Makefile
+++ b/Makefile
@@ -846,7 +846,7 @@ generated-hdrs: $(GENERATED_H)
 ## Exhaustive lists of our source files, either dynamically generated,
 ## or hardcoded.
 SOURCES_CMD = ( \
-	git ls-files \
+	git ls-files --deduplicate \
 		'*.[hcS]' \
 		'*.sh' \
 		':!*[tp][0-9][0-9][0-9][0-9]*' \
-- 
2.36.0.1.g15c4090757