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