Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

[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

In this patch, foreach --recursive acts depth-first, much like the default
behavior described in the patch by Imram Yousuf in this
post <http://marc.info/?l=git&m=121066084508631&w=2>.
Changes were made so that the submodule "Entering ..." message was right
next to the output generated by the command too.
It also adds the --parent option for executing the command in the
supermodule as well.

I began by adding a --depth option, to preserve the original --recursive
behavior, and the --parent option, and trying to get that to work. However,
I pretty much confused myself for a while trying to straighten that out, so
I just ended up modifying the --recursive behavior.
If the --recursive behavior should be preserved, I could add the --depth
option back and only have --parent affect non-recursive and --depth
recursive behavior.

I had kind-of implemented this behavior with aliases / bash functions
(posted to pastebin <http://pastebin.com/yLHe9XWy>
, spurned by a
question I asked in StackOverflow <http://stackoverflow.com/q/14846967/170413>),
however I would always run into issues with escaping characters when
passing from the bash functions to git aliases (i.e., putting "'ello" as an
test commit message). I also tried out mb14's method from the StackOverflow
post, but I ran into the same issues.
Figured the best way to avoid that was to cut out the extra layers.

I've attached a test script to generate the tree that VonC suggested with
output showing the iteration.

Attachments

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