Re: [PATCH 3/3] completion: match ctags symbol names in grep patterns

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 3/3] completion: match ctags symbol names in grep patterns

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:17

Jonathan Nieder [off-list ref] writes:
Junio C Hamano wrote:
quoted
Perhaps something like this is in order?
[...]
quoted
+++ b/Makefile
@@ -2127,17 +2127,25 @@ po/git.pot: $(LOCALIZED_C)
 
 pot: po/git.pot
 
+git_check = $(shell git ls-files >/dev/null 2>&1; echo $$?)
+ifeq ($(git_check),0)
+FIND_SOURCE_FILES = git ls-files '*.[hcS]'
+else
+FIND_SOURCE_FILES = $(FIND) . \( -name .git -type d -prune \) \
+		-o \( -name '*.[hcS]' -type f -print \)
+endif
Neat.  I'd prefer something like

	FIND_SOURCE_FILES = \
		git ls-files '*.[hcS]' 2>/dev/null || \
		$(FIND) . -name .git -prune -o -name '*.[hcS]' -type f -print

that avoid punishing people who were using the makefile for some
purpose unrelated to tags and cscope, though. ;)
Hmm, how would this punish anybody exactly (I just took the structure
from the way how the auto-depend is done)?

Besides, you would need to have the whole thing in a subshell or
something, as this is used as the upstream to "| xargs".

Re: [PATCH 3/3] completion: match ctags symbol names in grep patterns

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:52:17

Junio C Hamano wrote:
Jonathan Nieder [off-list ref] writes:
quoted
Junio C Hamano wrote:
quoted
quoted
+git_check = $(shell git ls-files >/dev/null 2>&1; echo $$?)
[...]
quoted
Neat.  I'd prefer something like
[...]
quoted
that avoid punishing people who were using the makefile for some
purpose unrelated to tags and cscope, though. ;)
Hmm, how would this punish anybody exactly (I just took the structure
from the way how the auto-depend is done)?
As Matthieu mentioned, the code in $(shell ...) gets run once each
time the makefile is loaded, adding to the runtime and possible
failure modes of

	make clean

that does not care about the result.  The dep_check test has that same
problem, and I was a little nervous about that when we added it.  But:

 i.   it seemed to be worth the convenience

 ii.  computing whether the compiler supports -MMD once each time $(CC)
      is launched would slow enough not to be an option

 iii. in the end, most uses of the makefile are to compile something,
      anyway, so it is not _that_ much of a waste.

 iv.  if someone finds the per-make-invocation to be too high, we
      could introduce a DONT_COMPUTE_HEADER_DEPENDENCIES variable that
      causes the check to be skipped by forcing that particular result.

Great.

In this new tags/cscope example, one could make an argument that
running exactly once is similarly better than running as needed (as in
(ii) above), by pointing out that

	make tags TAGS cscope

would have to check for a working "git ls-files" once instead of three
times.  But I don't buy it. :)
Besides, you would need to have the whole thing in a subshell or
something, as this is used as the upstream to "| xargs".
Good catch, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help