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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:56:18

Heiko Voigt [off-list ref] writes:
On Mon, Mar 04, 2013 at 03:00:45PM -0800, Junio C Hamano wrote:
quoted
So if you want a single boolean to toggle between the current
behaviour and the other one, it would be --post-order.  But you may
at least want to consider pros and cons of allowing users to give
two separate commands, one for the pre-order visitation (which is
the current "command") and the other for the post-order
visitation. Being able to run both might turn out to be useful.
I second that. Having a --post-order=<command/script> switch will give
us much more flexibility. For ease of use we could allow --post-order
without command to switch the meaning of the main command.

So a final solution would have these switches:

git submodule foreach ... [--pre-order[=<command>]] [--post-order[=<command>]] [<command>]

If only --pre-order without argument is given the command will be
executed pre-order. If only --post-order the command will be executed
post-order. If both are given its an error and so on...

There are some combinations we would need to catch as errors but this
design should allow a step by step implementation:

	1. just the --post-order switch
	2. --post-order with argument switch
	3. --pre-order (including argument) for symmetry of usage
Yeah, I think I can agree with that direction, and Eric's patch
could be that first step of the three-step progression, without
painting us into a corner we cannot get out of when we want to
advance to 2 and 3 later.

I was more interested in the design aspect and I didn't look at the
actual patch text, though.

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

From: Eric Cousineau <hidden>
Date: 2016-06-15 22:56:18

On Tue, Mar 5, 2013 at 10:09 AM, Junio C Hamano [off-list ref] wrote:
Heiko Voigt [off-list ref] writes:
quoted
On Mon, Mar 04, 2013 at 03:00:45PM -0800, Junio C Hamano wrote:
quoted
So if you want a single boolean to toggle between the current
behaviour and the other one, it would be --post-order.  But you may
at least want to consider pros and cons of allowing users to give
two separate commands, one for the pre-order visitation (which is
the current "command") and the other for the post-order
visitation. Being able to run both might turn out to be useful.
I second that. Having a --post-order=<command/script> switch will give
us much more flexibility. For ease of use we could allow --post-order
without command to switch the meaning of the main command.

So a final solution would have these switches:

git submodule foreach ... [--pre-order[=<command>]] [--post-order[=<command>]] [<command>]

If only --pre-order without argument is given the command will be
executed pre-order. If only --post-order the command will be executed
post-order. If both are given its an error and so on...

There are some combinations we would need to catch as errors but this
design should allow a step by step implementation:

      1. just the --post-order switch
      2. --post-order with argument switch
      3. --pre-order (including argument) for symmetry of usage
Yeah, I think I can agree with that direction, and Eric's patch
could be that first step of the three-step progression, without
painting us into a corner we cannot get out of when we want to
advance to 2 and 3 later.

I was more interested in the design aspect and I didn't look at the
actual patch text, though.
Would these be the correct behaviors of Heiko's implementation?

git submodule foreach # Empty command, pre-order
git submodule foreach --pre-order # Same behavior
git submodule foreach --post-order # Empty command, post-order
git submodule foreach 'frotz' # Do 'frotz' pre-order in each submodule
git submodule foreach --post-order 'frotz' # Do 'frotz' post-order in
each submodule
git submodule foreach --pre-order='frotz' --post-order='shimmy' # Do
'frotz' pre-order and 'shimmy' post-order in each submodule
git submodule foreach --post-order='shimmy' 'frotz' # Invalid usage of
the command
git submodule foreach --post-order --pre-order #

It should not be too hard to have this functionality affect the
--include-super command as well.

And would it be worth it to abstract this traversal to expose it to
other commands, such as 'update', to consolidate the code some?
I think Imram was doing something like that in his post.

- Eric
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help