{"thread":{"id":"37679","subject":"let git grep consider sub projects","startedAt":"2014-10-07T08:29:14Z","lastAt":"2014-10-08T07:31:40Z","messageCount":7,"participants":["Olaf Hering","Junio C Hamano","Mikael Magnusson","Jens Lehmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"250276","messageId":"20141007082914.GA2729@aepfle.de","threadId":"37679","inReplyTo":null,"subject":"let git grep consider sub projects","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-10-07T08:29:14Z","receivedAt":"2014-10-07T08:29:14Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"\nHow can I teach 'git grep $string' to also consider subprojects?\n\nThe build system of xen.git clones 4 other trees into a directory in its\nsource tree during build. It would be nice if my 'git grep' searches\nalso in these cloned subdirs. Somehow there must be some knowledge\nbecause 'git clean -dfx' leaves them alone, while 'git clean -dffx'\nwipes everything.\n\nOlaf\n\nPS: Sometimes I miss a 'git clean -dfx --also-sub-repos' useful to\nreally clean everything before starting over.\n"},{"id":"250299","messageId":"xmqq8ukrg2j2.fsf@gitster.dls.corp.google.com","threadId":"37679","inReplyTo":"20141007082914.GA2729@aepfle.de","subject":"Re: let git grep consider sub projects","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-10-07T18:25:53Z","receivedAt":"2014-10-07T18:25:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olaf Hering <olaf@aepfle.de> writes:\n\n> How can I teach 'git grep $string' to also consider subprojects?\n>\n> The build system of xen.git clones 4 other trees into a directory in its\n> source tree during build. It would be nice if my 'git grep' searches\n> also in these cloned subdirs. Somehow there must be some knowledge\n> because 'git clean -dfx' leaves them alone, while 'git clean -dffx'\n> wipes everything.\n>\n> Olaf\n>\n> PS: Sometimes I miss a 'git clean -dfx --also-sub-repos' useful to\n> really clean everything before starting over.\n\nIs \"submodule foreach\" under-advertised or with less than adequate\nfeatures?\n"},{"id":"250302","messageId":"CAHYJk3Qrj3QfBK-MkcCS2AmyTz=AgCcruq7Df-YZKW24LMWTHg@mail.gmail.com","threadId":"37679","inReplyTo":"xmqq8ukrg2j2.fsf@gitster.dls.corp.google.com","subject":"Re: let git grep consider sub projects","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2014-10-07T19:12:46Z","receivedAt":"2014-10-07T19:12:46Z","isPatch":false,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"On 7 October 2014 20:25, Junio C Hamano <gitster@pobox.com> wrote:\n> Olaf Hering <olaf@aepfle.de> writes:\n>\n>> How can I teach 'git grep $string' to also consider subprojects?\n>>\n>> The build system of xen.git clones 4 other trees into a directory in its\n>> source tree during build. It would be nice if my 'git grep' searches\n>> also in these cloned subdirs. Somehow there must be some knowledge\n>> because 'git clean -dfx' leaves them alone, while 'git clean -dffx'\n>> wipes everything.\n>>\n>> Olaf\n>>\n>> PS: Sometimes I miss a 'git clean -dfx --also-sub-repos' useful to\n>> really clean everything before starting over.\n>\n> Is \"submodule foreach\" under-advertised or with less than adequate\n> features?\n\nIt sounds like in these use cases, you would want the commands to run\non all the submodules but also in the parent repo, am I wrong in\nthinking that git submodule foreach does only the former part? So you\nwould either need to make a wrapper thing yourself or run the command\ntwice.\n\nIn the first case with the git grep, I can also imagine that with some\nnontrivial patterns, having to quote the metacharacters not only once,\nbut twice, can be a significant annoyance. Eg, first protect it from\ngit submodule foreach parsing it, and then from the shell running the\nindividual commands.\n\n-- \nMikael Magnusson\n"},{"id":"250331","messageId":"5434DE29.2010200@web.de","threadId":"37679","inReplyTo":"CAHYJk3Qrj3QfBK-MkcCS2AmyTz=AgCcruq7Df-YZKW24LMWTHg@mail.gmail.com","subject":"Re: let git grep consider sub projects","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2014-10-08T06:48:09Z","receivedAt":"2014-10-08T06:48:09Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 07.10.2014 um 21:12 schrieb Mikael Magnusson:\n> On 7 October 2014 20:25, Junio C Hamano <gitster@pobox.com> wrote:\n>> Olaf Hering <olaf@aepfle.de> writes:\n>>\n>>> How can I teach 'git grep $string' to also consider subprojects?\n>>>\n>>> The build system of xen.git clones 4 other trees into a directory in its\n>>> source tree during build. It would be nice if my 'git grep' searches\n>>> also in these cloned subdirs. Somehow there must be some knowledge\n>>> because 'git clean -dfx' leaves them alone, while 'git clean -dffx'\n>>> wipes everything.\n>>>\n>>> Olaf\n>>>\n>>> PS: Sometimes I miss a 'git clean -dfx --also-sub-repos' useful to\n>>> really clean everything before starting over.\n>>\n>> Is \"submodule foreach\" under-advertised or with less than adequate\n>> features?\n>\n> It sounds like in these use cases, you would want the commands to run\n> on all the submodules but also in the parent repo, am I wrong in\n> thinking that git submodule foreach does only the former part? So you\n> would either need to make a wrapper thing yourself or run the command\n> twice.\n\nYep, the workaround for a command \"git foo\" that hasn't learned the\n--recurse-submodules option yet is\n\n    git foo && git submodule foreach --recursive git foo\n\n> In the first case with the git grep, I can also imagine that with some\n> nontrivial patterns, having to quote the metacharacters not only once,\n> but twice, can be a significant annoyance. Eg, first protect it from\n> git submodule foreach parsing it, and then from the shell running the\n> individual commands.\n\nThe long term goal is to teach git grep and git clean - and others -\nthe --recurse-submodules option. I'd be happy to help if someone\nwants to work on that, as I'm busy working on another topic.\n"},{"id":"250332","messageId":"20141008065947.GA22318@aepfle.de","threadId":"37679","inReplyTo":"5434DE29.2010200@web.de","subject":"Re: let git grep consider sub projects","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-10-08T06:59:47Z","receivedAt":"2014-10-08T06:59:47Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Wed, Oct 08, Jens Lehmann wrote:\n\n>    git foo && git submodule foreach --recursive git foo\n\nLooks like a submodule is yet another thing, or I have to learn what a\nsubmodule is:\n\nolaf@bax:~/xen $ find . -name .git\n./.git\n./tools/qemu-xen-dir-remote/.git\n./tools/qemu-xen-traditional-dir-remote/.git\n./tools/firmware/seabios-dir-remote/.git\nolaf@bax:~/xen $ git submodule foreach --recursive git show\nolaf@bax:~/xen $\n\nxen does essentially 'git clone $url1 dir/url1-dir;git clone $url2\ndir/url2-dir'. So the top level .git does not really know about\ndir/*-dir.\n\nOlaf\n"},{"id":"250334","messageId":"5434E6B5.3030605@web.de","threadId":"37679","inReplyTo":"20141008065947.GA22318@aepfle.de","subject":"Re: let git grep consider sub projects","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2014-10-08T07:24:37Z","receivedAt":"2014-10-08T07:24:37Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 08.10.2014 um 08:59 schrieb Olaf Hering:\n> On Wed, Oct 08, Jens Lehmann wrote:\n>\n>>     git foo && git submodule foreach --recursive git foo\n>\n> Looks like a submodule is yet another thing, or I have to learn what a\n> submodule is:\n>\n> olaf@bax:~/xen $ find . -name .git\n> ./.git\n> ./tools/qemu-xen-dir-remote/.git\n> ./tools/qemu-xen-traditional-dir-remote/.git\n> ./tools/firmware/seabios-dir-remote/.git\n> olaf@bax:~/xen $ git submodule foreach --recursive git show\n> olaf@bax:~/xen $\n>\n> xen does essentially 'git clone $url1 dir/url1-dir;git clone $url2\n> dir/url2-dir'. So the top level .git does not really know about\n> dir/*-dir.\n\nOkay, I just checked that xen doesn't use submodules but uses simple\nembedded repos ignored by the .gitignore file. From a quick glance\nit looks like handling the sub projects is scripted in the Makefiles.\nThis is perfectly fine, but then you can't really expect git commands\nto know about these sub projects. Or am I missing something?\n"},{"id":"250335","messageId":"20141008073140.GA28807@aepfle.de","threadId":"37679","inReplyTo":"5434E6B5.3030605@web.de","subject":"Re: let git grep consider sub projects","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2014-10-08T07:31:40Z","receivedAt":"2014-10-08T07:31:40Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"On Wed, Oct 08, Jens Lehmann wrote:\n\n> Okay, I just checked that xen doesn't use submodules but uses simple\n> embedded repos ignored by the .gitignore file. From a quick glance\n> it looks like handling the sub projects is scripted in the Makefiles.\n> This is perfectly fine, but then you can't really expect git commands\n> to know about these sub projects. Or am I missing something?\n\nI just did not know about the submodule command. And I did not realize\nthat they are in .gitignore, which should have been obvious.\n\nI will check if using submodule instead of plain clone can be done,\nwithout breaking anyones workflow.\n\n\nOlaf\n"}]}