{"thread":{"id":"44705","subject":"[PATCH 0/4] \"make tags\" improvements","startedAt":"2016-12-14T14:25:43Z","lastAt":"2016-12-14T14:33:00Z","messageCount":5,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"307773","messageId":"20161214142533.svktxk63eiwaaeor@sigill.intra.peff.net","threadId":"44705","inReplyTo":null,"subject":"[PATCH 0/4] \"make tags\" improvements","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-14T14:25:34Z","receivedAt":"2016-12-14T14:25:43Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"A discussion earlier today made me notice that our \"make tags\" target\nincludes some cruft that we shouldn't be indexing. This fixes that, and\nstarts indexing some of the shell scripts, which is something I've been\ndoing in a hacky way for a while. It's very convenient when working on\nthe test suite (especially because I can never remember which functions\nare declared in test-lib.sh, and which in test-lib-functions.sh).\n\n  [1/4]: Makefile: reformat FIND_SOURCE_FILES\n  [2/4]: Makefile: exclude test cruft from FIND_SOURCE_FILES\n  [3/4]: Makefile: match shell scripts in FIND_SOURCE_FILES\n  [4/4]: Makefile: exclude contrib from FIND_SOURCE_FILES\n\n Makefile | 19 ++++++++++++++++---\n 1 file changed, 16 insertions(+), 3 deletions(-)\n\n-Peff\n"},{"id":"307774","messageId":"20161214142655.boepotpgwgrdnldz@sigill.intra.peff.net","threadId":"44705","inReplyTo":"20161214142533.svktxk63eiwaaeor@sigill.intra.peff.net","subject":"[PATCH 1/4] Makefile: reformat FIND_SOURCE_FILES","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-14T14:26:55Z","receivedAt":"2016-12-14T14:27:03Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"As we add to this in future commits, the formatting is going\nto make it harder and harder to read. Let's write it more as\nwe would in a shell script, putting each logical block on\nits own line.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nJust to make the other patches easier to read; no behavior change\nintended.\n\nI was tempted to actually pull this out into its own\nfind-source-files.sh script. I don't know if that is\npreferable or not; it certainly makes the \"make tags\"\noutput less ugly.\n\n Makefile | 9 ++++++---\n 1 file changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex f53fcc90d..f42b1953d 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2149,9 +2149,12 @@ endif\n po/build/locale/%/LC_MESSAGES/git.mo: po/%.po\n \t$(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<\n \n-FIND_SOURCE_FILES = ( git ls-files '*.[hcS]' 2>/dev/null || \\\n-\t\t\t$(FIND) . \\( -name .git -type d -prune \\) \\\n-\t\t\t\t-o \\( -name '*.[hcS]' -type f -print \\) )\n+FIND_SOURCE_FILES = ( \\\n+\tgit ls-files '*.[hcS]' 2>/dev/null || \\\n+\t$(FIND) . \\\n+\t\t\\( -name .git -type d -prune \\) \\\n+\t\t-o \\( -name '*.[hcS]' -type f -print \\) \\\n+\t)\n \n $(ETAGS_TARGET): FORCE\n \t$(RM) $(ETAGS_TARGET)\n-- \n2.11.0.341.g202cd3142\n\n"},{"id":"307775","messageId":"20161214142804.b6q7enowcavagmam@sigill.intra.peff.net","threadId":"44705","inReplyTo":"20161214142533.svktxk63eiwaaeor@sigill.intra.peff.net","subject":"[PATCH 2/4] Makefile: exclude test cruft from FIND_SOURCE_FILES","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-14T14:28:04Z","receivedAt":"2016-12-14T14:28:12Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"The test directory may contain three types of files that\nmatch our patterns:\n\n  1. Helper programs in t/helper.\n\n  2. Sample data files (e.g., t/t4051/hello.c).\n\n  3. Untracked cruft in trash directories and t/perf/build.\n\nWe want to match (1), but not the other two, as they just\nclutter up the list.\n\nFor the ls-files method, we can drop (2) with a negative\npathspec. We do not have to care about (3), since ls-files\nwill not list untracked files.\n\nFor `find`, we can match both cases with `-prune` patterns.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI expected that:\n\n  ':![tp][0-9][0-9][0-9][0-9]'\n\nwould work, but it doesn't. I think because we don't match intermediate\ndirectories against pathspecs. So you have to use wildcards to match the\nrest of the path.\n\n Makefile | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex f42b1953d..001126931 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2150,9 +2150,15 @@ po/build/locale/%/LC_MESSAGES/git.mo: po/%.po\n \t$(QUIET_MSGFMT)mkdir -p $(dir $@) && $(MSGFMT) -o $@ $<\n \n FIND_SOURCE_FILES = ( \\\n-\tgit ls-files '*.[hcS]' 2>/dev/null || \\\n+\tgit ls-files \\\n+\t\t'*.[hcS]' \\\n+\t\t':!*[tp][0-9][0-9][0-9][0-9]*' \\\n+\t\t2>/dev/null || \\\n \t$(FIND) . \\\n \t\t\\( -name .git -type d -prune \\) \\\n+\t\t-o \\( -name '[tp][0-9][0-9][0-9][0-9]' -type d -prune \\) \\\n+\t\t-o \\( -name build -type d -prune \\) \\\n+\t\t-o \\( -name 'trash*' -type d -prune \\) \\\n \t\t-o \\( -name '*.[hcS]' -type f -print \\) \\\n \t)\n \n-- \n2.11.0.341.g202cd3142\n\n"},{"id":"307776","messageId":"20161214142944.xqwkk2zjeyqk3gfr@sigill.intra.peff.net","threadId":"44705","inReplyTo":"20161214142533.svktxk63eiwaaeor@sigill.intra.peff.net","subject":"[PATCH 3/4] Makefile: match shell scripts in FIND_SOURCE_FILES","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-14T14:29:44Z","receivedAt":"2016-12-14T14:30:14Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"We feed FIND_SOURCE_FILES to ctags to help developers\nnavigate to particular functions, but we only feed C source\ncode. The same feature can be helpful when working with\nshell scripts (especially the test suite). Modern versions\nof ctags know how to parse shell scripts; we just need to\nfeed the filenames to it.\n\nThis patch specifically avoids including the individual test\nscripts themselves. Those are unlikely to be of interest,\nand there are a lot of them to process. It does pick up\ntest-lib.sh and test-lib-functions.sh.\n\nNote that our negative pathspec already excludes the\nindividual scripts for the ls-files case, but we need to\nloosen the `find` rule to match it.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nMaybe people would find this annoying. It does increase the number of\nentries in the tags file. I've been running something like it for a few\nmonths and have found it useful.\n\nIt's also possible that some people have a version of ctags or etags\nthat doesn't handle shell scripts. I imagine few enough people actually\nrun \"make tags\" in the first place that we can probably try it and see.\n\n Makefile | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 001126931..ef8de4a75 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2152,14 +2152,16 @@ po/build/locale/%/LC_MESSAGES/git.mo: po/%.po\n FIND_SOURCE_FILES = ( \\\n \tgit ls-files \\\n \t\t'*.[hcS]' \\\n+\t\t'*.sh' \\\n \t\t':!*[tp][0-9][0-9][0-9][0-9]*' \\\n \t\t2>/dev/null || \\\n \t$(FIND) . \\\n \t\t\\( -name .git -type d -prune \\) \\\n-\t\t-o \\( -name '[tp][0-9][0-9][0-9][0-9]' -type d -prune \\) \\\n+\t\t-o \\( -name '[tp][0-9][0-9][0-9][0-9]*' -prune \\) \\\n \t\t-o \\( -name build -type d -prune \\) \\\n \t\t-o \\( -name 'trash*' -type d -prune \\) \\\n \t\t-o \\( -name '*.[hcS]' -type f -print \\) \\\n+\t\t-o \\( -name '*.sh' -type f -print \\) \\\n \t)\n \n $(ETAGS_TARGET): FORCE\n-- \n2.11.0.341.g202cd3142\n\n"},{"id":"307777","messageId":"20161214143234.pvtvn456ijltvueu@sigill.intra.peff.net","threadId":"44705","inReplyTo":"20161214142533.svktxk63eiwaaeor@sigill.intra.peff.net","subject":"[PATCH 4/4] Makefile: exclude contrib from FIND_SOURCE_FILES","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-12-14T14:32:35Z","receivedAt":"2016-12-14T14:33:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"When you're working on the git project, you're unlikely to\ncare about random bits in contrib/ (e.g., you would not want\nto jump to the copy of xmalloc in the wincred credential\nhelper). Nobody has really complained because there are\nrelatively few C files in contrib.\n\nNow that we're matching shell scripts, too, we get quite a\nfew more hits, especially in the obsolete contrib/examples\ndirectory. Looking for usage() should turn up the one in\ngit-sh-setup, not in some long-dead version of git-clone.\n\nLet's just exclude all of contrib. Any specific projects\nthere which are big enough to want tags can generate them\nseparately.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n Makefile | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex ef8de4a75..76267262c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2154,10 +2154,12 @@ FIND_SOURCE_FILES = ( \\\n \t\t'*.[hcS]' \\\n \t\t'*.sh' \\\n \t\t':!*[tp][0-9][0-9][0-9][0-9]*' \\\n+\t\t':!contrib' \\\n \t\t2>/dev/null || \\\n \t$(FIND) . \\\n \t\t\\( -name .git -type d -prune \\) \\\n \t\t-o \\( -name '[tp][0-9][0-9][0-9][0-9]*' -prune \\) \\\n+\t\t-o \\( -name contrib -type d -prune \\) \\\n \t\t-o \\( -name build -type d -prune \\) \\\n \t\t-o \\( -name 'trash*' -type d -prune \\) \\\n \t\t-o \\( -name '*.[hcS]' -type f -print \\) \\\n-- \n2.11.0.341.g202cd3142\n"}]}