Skip to content

Commit 604a646

Browse files
committed
Makefile: dedup list of files obtained from ls-files
Since 3353397 ("Makefile: ask "ls-files" to list source files if available", 2011-10-18), we optionally asked "ls-files" to list the source files that ought to exist, as a faster approximation for "find" on working tree files. This works reasonably well, except that it ends up listing the same path multiple times if the index is unmerged. Because the original use of this construct was to name files to run etags over, and the etags command happily takes the same filename multiple times without causing any harm, there was no problem (other than perhaps spending slightly more cycles, but who cares how fast the TAGS file gets updated). We however recently added a similar call to "ls-files" to list *.h files, instead of using "find", in 92b88eb ("Makefile: use `git ls-files` to list header files, if possible", 2019-03-04). In this new use of "ls-files", the resulting list $(LIB_H) is used for, among other things, generating the header files to run hdr-check target, and the duplicate unfortunately becomes a true problem. It causes $(MAKE) to notice that there are multiple %.hco targets and complain. Let the resulting list consumed by $(sort), which deduplicates, to fix this. Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 14c0f8d commit 604a646

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,12 +822,12 @@ VCSSVN_LIB = vcs-svn/lib.a
822822

823823
GENERATED_H += command-list.h
824824

825-
LIB_H := $(shell git ls-files '*.h' ':!t/' ':!Documentation/' 2>/dev/null || \
825+
LIB_H := $(sort $(shell git ls-files '*.h' ':!t/' ':!Documentation/' 2>/dev/null || \
826826
$(FIND) . \
827827
-name .git -prune -o \
828828
-name t -prune -o \
829829
-name Documentation -prune -o \
830-
-name '*.h' -print)
830+
-name '*.h' -print))
831831

832832
LIB_OBJS += abspath.o
833833
LIB_OBJS += advice.o

0 commit comments

Comments
 (0)