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

Re: let git grep consider sub projects

From
MMMikael Magnusson <mikachu@gmail.com>
Date
Oct 7, 2014, 19:12 UTC
Message-ID
<CAHYJk3Qrj3QfBK-MkcCS2AmyTz=AgCcruq7Df-YZKW24LMWTHg@mail.gmail.com>
In-Reply-To
<xmqq8ukrg2j2.fsf@gitster.dls.corp.google.com>
On 7 October 2014 20:25, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Olaf Hering <olaf@aepfle.de> writes:
>
>> How can I teach 'git grep $string' to also consider subprojects?
>>
>> The build system of xen.git clones 4 other trees into a directory in its
>> source tree during build. It would be nice if my 'git grep' searches
>> also in these cloned subdirs. Somehow there must be some knowledge
>> because 'git clean -dfx' leaves them alone, while 'git clean -dffx'
>> wipes everything.
>>
>> Olaf
>>
>> PS: Sometimes I miss a 'git clean -dfx --also-sub-repos' useful to
>> really clean everything before starting over.
>
> Is "submodule foreach" under-advertised or with less than adequate
> features?

It sounds like in these use cases, you would want the commands to run on all the submodules but also in the parent repo, am I wrong in thinking that git submodule foreach does only the former part? So you would either need to make a wrapper thing yourself or run the command twice.

In the first case with the git grep, I can also imagine that with some nontrivial patterns, having to quote the metacharacters not only once, but twice, can be a significant annoyance. Eg, first protect it from git submodule foreach parsing it, and then from the shell running the individual commands.

-- 
Mikael Magnusson
Previous: Junio C HamanoNext: Jens Lehmann
Message 3 of 7 in “let git grep consider sub projects”
  1. Olaf HeringOct 7, 2014
  2. Junio C HamanoOct 7, 2014
  3. Mikael MagnussonOct 7, 2014
  4. Jens LehmannOct 8, 2014
  5. Olaf HeringOct 8, 2014
  6. Jens LehmannOct 8, 2014
  7. Olaf HeringOct 8, 2014

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.