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

Re: [PATCH/RFC] Changing submodule foreach --recursive to be depth-first, --parent option to execute command in supermodule as well

From
Heiko Voigt <hvoigt@hvoigt.net>
Date
Mar 11, 2013, 16:46 UTC
Message-ID
<20130311164628.GA4167@sandbox-ub.fritz.box>
In-Reply-To
<513B7D08.20406@web.de>
On Sat, Mar 09, 2013 at 07:18:48PM +0100, Jens Lehmann wrote:
Show 18 quoted lines
> Am 05.03.2013 22:17, schrieb Phil Hord:
> > In a shell, it usually goes like this:
> > 
> >    git submodule foreach --recursive '${cmd}'
> >    <up><home><del>{30-ish}<end><backspace><enter>
> > 
> > It'd be easier if I could just include a switch for this, and maybe
> > even create an alias for it.  But maybe this is different command
> > altogether.
> 
> Are you sure you wouldn't forget to provide such a switch too? ;-)
> 
> I'm still not convinced we should add a new switch, as it can easily
> be achieved by adding "${cmd} &&" to your scripts. And on the command
> line you could use an alias like this one to achieve that:
> 
> [alias]
> 	recurse = !sh -c \"$@ && git submodule foreach --recursive $@\"

I also think it would be useful to have a switch (or even configuration) to include the superproject.

The following (quite typical) use cases come to my mind:

# Assuming some not yet existing configuration values git config submodule.recursive true git config submodule.includeSuper true

# commit your work over the whole tree into one branch git submodule foreach git checkout -b hv/my-super-cool-feature git submodule foreach --post-order git commit -a -m "DRAFT: finished work for today" git submodule foreach git push hvoigt hv/my-super-cool-feature

# cleanup git submodule foreach git clean -xfd

# reset git submodule foreach git reset --hard

...

Assuming you have a submodule heavy project and you work on multiple submodules including the superproject. These are quite typical commands you would use during development of your feature I imagine. Once you are finished you need to get your feature upstream by the individual submodule rules.

On a feature branch during development there is nothing wrong in simply doing full cross-submodule project commits.

At some point we will probably extend the above commands with a --recurse-submodules switch but until then this is a good substitute so why not have a --include-super maybe even as a configuration option ?

Cheers Heiko
Previous: Jens LehmannNext: Phil Hord
Message 12 of 25 in “Changing submodule foreach --recursive to be depth-first, --parent option to execute command in supermodule as well”
  1. Changing submodule foreach --recursive to be depth-first, --parent option to execute command in supermodule as wellEric Cousineau, Mar 4, 2013
  2. Jens LehmannMar 4, 2013
  3. Junio C HamanoMar 4, 2013
  4. Eric CousineauMar 5, 2013
  5. Heiko VoigtMar 5, 2013
  6. Junio C HamanoMar 5, 2013
  7. Eric CousineauMar 5, 2013
  8. Junio C HamanoMar 5, 2013
  9. Jens LehmannMar 5, 2013
  10. Phil HordMar 5, 2013
  11. Jens LehmannMar 9, 2013
  12. Heiko VoigtMar 11, 2013
  13. Phil HordMar 12, 2013
  14. Eric CousineauMar 14, 2013
  15. Jens LehmannMar 18, 2013
  16. Eric CousineauMar 26, 2013
  17. Jens LehmannApr 2, 2013
  18. submodule foreach: Added in --post-order=<command> and adjusted code per Jens Lehmann's suggestionseacousineau, Apr 13, 2013
  19. Jens LehmannApr 14, 2013
  20. Jens LehmannMar 18, 2013
  21. Eric CousineauMar 26, 2013
  22. Eric CousineauMar 26, 2013
  23. Junio C HamanoMar 26, 2013
  24. Junio C HamanoMar 26, 2013
  25. Eric CousineauApr 13, 2013

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.