git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] grep: --full-tree

From
Jeff King <peff@peff.net>
Date
Nov 25, 2009, 20:39 UTC
Message-ID
<20091125203922.GA18487@coredump.intra.peff.net>
In-Reply-To
<7vk4xggv27.fsf@alter.siamese.dyndns.org>
On Tue, Nov 24, 2009 at 12:56:32AM -0800, Junio C Hamano wrote:
>  * In http://article.gmane.org/gmane.comp.version-control.git/111717, I
>    once argued in the opposite way, but I think it is Ok to aim for making
>    the default --full-tree in the longer run (cf. $gmane/127885).  This is
>    the first step in that direction.

Ironically, I argued for --full-tree behavior in the same thread, but have since softened my view. What I have come to realize is that (for me, anyway) it is very dependent on the organization of the project you are working on.

For git.git, and most of my small-ish other projects, I want "git grep" to search the full tree. But recently, I have been working on a large-ish project imported from svn where the parts of interest to me are rooted two directories deep (i.e., I am working in "linux/subproject/", and I don't care at all what's happening in "windows/otherproject"). I don't want grep hits from the other area to clutter my output, and I especially don't want to waste time hitting the disk for those pages, which are an order of magnitude larger than the working set of files that are actually of interest to me.

On top of that, I think there are two ways within a logical subproject to use subdirectories. In git.git, I tend to actually chdir into Documentation/ or t/, because they have their own Makefiles. But for a project that organizes its code into a bunch of module subdirectories all driven by a top-level non-recursive Makefile, I tend to stay at the root and actually do "vi module/foo.c; make".

So what that tells me is:
  1. It is not necessarily the _developer_, but a combination of
     developer and project that decides which behavior (of --full-tree
     and the current behavior) is more useful. Which to me really points
     to the utility of a config option.
  2. It would be useful to have a "partial-tree" middle ground. In other
     words, if I am in "linux/subproject/t", I would find it most
     useful if "git grep" searched all of "linux/subproject".
     Implementing that would become much more complex, though. Probably
     the user would specify a list of rooted subprojects, and we would
     prefix-match our path to find which one we were in, and then
     do a full-tree grep on that subtree.
     And yes, this is somewhat an argument in favor of splitting the
     project into submodules. But I'd really rather not do that. They
     introduce significant complexity, and the rest of git is so _good_
     at ignoring uninteresting parts.
-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 12 of 68 in “grep: --full-tree”
  1. grep: --full-treeJunio C Hamano, Nov 24, 2009
  2. Michael J GruberNov 25, 2009
  3. Junio C HamanoNov 25, 2009
  4. Sverre RabbelierNov 25, 2009
  5. Junio C HamanoNov 25, 2009
  6. Sverre RabbelierNov 25, 2009
  7. Junio C HamanoNov 25, 2009
  8. Sverre RabbelierNov 25, 2009
  9. Johannes SchindelinNov 25, 2009
  10. Sverre RabbelierNov 25, 2009
  11. Jeff KingNov 25, 2009
  12. Jeff KingNov 25, 2009
  13. Junio C HamanoNov 25, 2009
  14. Jeff KingNov 25, 2009
  15. Junio C HamanoNov 25, 2009
  16. Jeff KingNov 25, 2009
  17. James PickensNov 25, 2009
  18. Jeff KingNov 25, 2009
  19. James PickensNov 26, 2009
  20. Jeff KingNov 27, 2009
  21. Junio C HamanoNov 27, 2009
  22. Johannes SchindelinNov 27, 2009
  23. Jeff KingNov 27, 2009
  24. Johannes SchindelinNov 27, 2009
  25. Uri OkrentNov 27, 2009
  26. Junio C HamanoNov 27, 2009
  27. Uri OkrentNov 27, 2009
  28. Jeff KingNov 27, 2009
  29. Uri OkrentNov 29, 2009
  30. Felipe ContrerasNov 29, 2009
  31. Jeff KingNov 27, 2009
  32. Johannes SchindelinNov 27, 2009
  33. Jeff KingNov 27, 2009
  34. Johannes SchindelinNov 29, 2009
  35. Jeff KingNov 29, 2009
  36. Junio C HamanoNov 29, 2009
  37. Felipe ContrerasNov 29, 2009
  38. Junio C HamanoNov 27, 2009
  39. Jeff KingNov 27, 2009
  40. Johannes SchindelinNov 29, 2009
  41. Jeff KingNov 29, 2009
  42. Matthieu MoyNov 27, 2009
  43. Johannes SchindelinNov 27, 2009
  44. Wincent ColaiutaNov 25, 2009
  45. Junio C HamanoNov 26, 2009
  46. A Large Angry SCMNov 26, 2009
  47. Junio C HamanoNov 26, 2009
  48. A Large Angry SCMNov 26, 2009
  49. Junio C HamanoNov 26, 2009
  50. James PickensNov 26, 2009
  51. Junio C HamanoNov 25, 2009
  52. Jeff KingNov 25, 2009
  53. A Large Angry SCMNov 25, 2009
  54. Jeff KingNov 25, 2009
  55. A Large Angry SCMNov 25, 2009
  56. Jeff KingNov 25, 2009
  57. Felipe ContrerasNov 29, 2009
  58. Uri OkrentNov 29, 2009
  59. Junio C HamanoNov 26, 2009
  60. Jeff KingNov 27, 2009
  61. A Large Angry SCMNov 25, 2009
  62. Junio C HamanoNov 25, 2009
  63. A Large Angry SCMNov 25, 2009
  64. A Large Angry SCMNov 25, 2009
  65. Johannes SchindelinNov 25, 2009
  66. Junio C HamanoNov 25, 2009
  67. Johannes SchindelinNov 26, 2009
  68. Junio C HamanoNov 26, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.