* [PATCH 1/4] Makefile: reformat FIND_SOURCE_FILES
2016-12-14 14:25 [PATCH 0/4] "make tags" improvements Jeff King
@ 2016-12-14 14:26 ` Jeff King
2016-12-14 14:28 ` [PATCH 2/4] Makefile: exclude test cruft from FIND_SOURCE_FILES Jeff King
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2016-12-14 14:26 UTC (permalink / raw)
To: git; +Cc: Chris Packham
As we add to this in future commits, the formatting is going
to make it harder and harder to read. Let's write it more as
we would in a shell script, putting each logical block on
its own line.
Signed-off-by: Jeff King <peff@peff.net>
---
Just to make the other patches easier to read; no behavior change
intended.
I was tempted to actually pull this out into its own
find-source-files.sh script. I don't know if that is
preferable or not; it certainly makes the "make tags"
output less ugly.
Makefile | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index f53fcc90d..f42b1953d 100644
--- a/Makefile
+++ b/Makefile
@@ -2149,9 +2149,12 @@ endif
po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
$(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
-FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \
- $(FIND) . \( -name .git -type d -prune \) \
- -o \( -name '*.[hcS]' -type f -print \) )
+FIND_SOURCE_FILES = ( \
+ git ls-files '*.[hcS]' 2>/dev/null || \
+ $(FIND) . \
+ \( -name .git -type d -prune \) \
+ -o \( -name '*.[hcS]' -type f -print \) \
+ )
$(ETAGS_TARGET): FORCE
$(RM) $(ETAGS_TARGET)
--
2.11.0.341.g202cd3142
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] Makefile: exclude test cruft from FIND_SOURCE_FILES
2016-12-14 14:25 [PATCH 0/4] "make tags" improvements Jeff King
2016-12-14 14:26 ` [PATCH 1/4] Makefile: reformat FIND_SOURCE_FILES Jeff King
@ 2016-12-14 14:28 ` Jeff King
2016-12-14 14:29 ` [PATCH 3/4] Makefile: match shell scripts in FIND_SOURCE_FILES Jeff King
2016-12-14 14:32 ` [PATCH 4/4] Makefile: exclude contrib from FIND_SOURCE_FILES Jeff King
3 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2016-12-14 14:28 UTC (permalink / raw)
To: git; +Cc: Chris Packham
The test directory may contain three types of files that
match our patterns:
1. Helper programs in t/helper.
2. Sample data files (e.g., t/t4051/hello.c).
3. Untracked cruft in trash directories and t/perf/build.
We want to match (1), but not the other two, as they just
clutter up the list.
For the ls-files method, we can drop (2) with a negative
pathspec. We do not have to care about (3), since ls-files
will not list untracked files.
For `find`, we can match both cases with `-prune` patterns.
Signed-off-by: Jeff King <peff@peff.net>
---
I expected that:
':![tp][0-9][0-9][0-9][0-9]'
would work, but it doesn't. I think because we don't match intermediate
directories against pathspecs. So you have to use wildcards to match the
rest of the path.
Makefile | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index f42b1953d..001126931 100644
--- a/Makefile
+++ b/Makefile
@@ -2150,9 +2150,15 @@ po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
$(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<
FIND_SOURCE_FILES = ( \
- git ls-files '*.[hcS]' 2>/dev/null || \
+ git ls-files \
+ '*.[hcS]' \
+ ':!*[tp][0-9][0-9][0-9][0-9]*' \
+ 2>/dev/null || \
$(FIND) . \
\( -name .git -type d -prune \) \
+ -o \( -name '[tp][0-9][0-9][0-9][0-9]' -type d -prune \) \
+ -o \( -name build -type d -prune \) \
+ -o \( -name 'trash*' -type d -prune \) \
-o \( -name '*.[hcS]' -type f -print \) \
)
--
2.11.0.341.g202cd3142
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] Makefile: match shell scripts in FIND_SOURCE_FILES
2016-12-14 14:25 [PATCH 0/4] "make tags" improvements Jeff King
2016-12-14 14:26 ` [PATCH 1/4] Makefile: reformat FIND_SOURCE_FILES Jeff King
2016-12-14 14:28 ` [PATCH 2/4] Makefile: exclude test cruft from FIND_SOURCE_FILES Jeff King
@ 2016-12-14 14:29 ` Jeff King
2016-12-14 14:32 ` [PATCH 4/4] Makefile: exclude contrib from FIND_SOURCE_FILES Jeff King
3 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2016-12-14 14:29 UTC (permalink / raw)
To: git; +Cc: Chris Packham
We feed FIND_SOURCE_FILES to ctags to help developers
navigate to particular functions, but we only feed C source
code. The same feature can be helpful when working with
shell scripts (especially the test suite). Modern versions
of ctags know how to parse shell scripts; we just need to
feed the filenames to it.
This patch specifically avoids including the individual test
scripts themselves. Those are unlikely to be of interest,
and there are a lot of them to process. It does pick up
test-lib.sh and test-lib-functions.sh.
Note that our negative pathspec already excludes the
individual scripts for the ls-files case, but we need to
loosen the `find` rule to match it.
Signed-off-by: Jeff King <peff@peff.net>
---
Maybe people would find this annoying. It does increase the number of
entries in the tags file. I've been running something like it for a few
months and have found it useful.
It's also possible that some people have a version of ctags or etags
that doesn't handle shell scripts. I imagine few enough people actually
run "make tags" in the first place that we can probably try it and see.
Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 001126931..ef8de4a75 100644
--- a/Makefile
+++ b/Makefile
@@ -2152,14 +2152,16 @@ po/build/locale/%/LC_MESSAGES/git.mo: po/%.po
FIND_SOURCE_FILES = ( \
git ls-files \
'*.[hcS]' \
+ '*.sh' \
':!*[tp][0-9][0-9][0-9][0-9]*' \
2>/dev/null || \
$(FIND) . \
\( -name .git -type d -prune \) \
- -o \( -name '[tp][0-9][0-9][0-9][0-9]' -type d -prune \) \
+ -o \( -name '[tp][0-9][0-9][0-9][0-9]*' -prune \) \
-o \( -name build -type d -prune \) \
-o \( -name 'trash*' -type d -prune \) \
-o \( -name '*.[hcS]' -type f -print \) \
+ -o \( -name '*.sh' -type f -print \) \
)
$(ETAGS_TARGET): FORCE
--
2.11.0.341.g202cd3142
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] Makefile: exclude contrib from FIND_SOURCE_FILES
2016-12-14 14:25 [PATCH 0/4] "make tags" improvements Jeff King
` (2 preceding siblings ...)
2016-12-14 14:29 ` [PATCH 3/4] Makefile: match shell scripts in FIND_SOURCE_FILES Jeff King
@ 2016-12-14 14:32 ` Jeff King
3 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2016-12-14 14:32 UTC (permalink / raw)
To: git; +Cc: Chris Packham
When you're working on the git project, you're unlikely to
care about random bits in contrib/ (e.g., you would not want
to jump to the copy of xmalloc in the wincred credential
helper). Nobody has really complained because there are
relatively few C files in contrib.
Now that we're matching shell scripts, too, we get quite a
few more hits, especially in the obsolete contrib/examples
directory. Looking for usage() should turn up the one in
git-sh-setup, not in some long-dead version of git-clone.
Let's just exclude all of contrib. Any specific projects
there which are big enough to want tags can generate them
separately.
Signed-off-by: Jeff King <peff@peff.net>
---
Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Makefile b/Makefile
index ef8de4a75..76267262c 100644
--- a/Makefile
+++ b/Makefile
@@ -2154,10 +2154,12 @@ FIND_SOURCE_FILES = ( \
'*.[hcS]' \
'*.sh' \
':!*[tp][0-9][0-9][0-9][0-9]*' \
+ ':!contrib' \
2>/dev/null || \
$(FIND) . \
\( -name .git -type d -prune \) \
-o \( -name '[tp][0-9][0-9][0-9][0-9]*' -prune \) \
+ -o \( -name contrib -type d -prune \) \
-o \( -name build -type d -prune \) \
-o \( -name 'trash*' -type d -prune \) \
-o \( -name '*.[hcS]' -type f -print \) \
--
2.11.0.341.g202cd3142
^ permalink raw reply related [flat|nested] 5+ messages in thread