All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Chris Packham <judge.packham@gmail.com>
Subject: [PATCH 2/4] Makefile: exclude test cruft from FIND_SOURCE_FILES
Date: Wed, 14 Dec 2016 09:28:04 -0500	[thread overview]
Message-ID: <20161214142804.b6q7enowcavagmam@sigill.intra.peff.net> (raw)
In-Reply-To: <20161214142533.svktxk63eiwaaeor@sigill.intra.peff.net>

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


  parent reply	other threads:[~2016-12-14 14:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161214142804.b6q7enowcavagmam@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=judge.packham@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.