From: Eric Cousineau <eacousineau@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] submodule foreach: Added in --post-order=<command> and adjusted code per Jens Lehmann's suggestions
Date: Fri, 12 Apr 2013 23:11:32 -0500 [thread overview]
Message-ID: <CA+aSAWviVWd3+89Wpv-1_6BSL=aN-u+60_oDXcyCG03enBmGTg@mail.gmail.com> (raw)
In-Reply-To: <CA+aSAWuK9Yhvx-vO1fUteq-K=xOPgxkyeWeHG3UwZuDHsxLzAw@mail.gmail.com>
Had accidentally sent this as HTML, resending as plain-text.
On Fri, Apr 12, 2013 at 11:09 PM, Eric Cousineau <eacousineau@gmail.com> wrote:
>
> Oops... I tried out using git-send-email adding in the Message-Id, but forgot to change the title as well. My bad.
>
> This was in response to:
>
> [PATCH/RFC] Changing submodule foreach --recursive to be depth-first, --parent option to execute command in supermodule as well
> Message-Id: <515B3C0E.9000802@web.de>
>
> - Eric
>
>
> On Fri, Apr 12, 2013 at 11:04 PM, eacousineau <eacousineau@gmail.com> wrote:
>>
>> Signed-off-by: eacousineau <eacousineau@gmail.com>
>> ---
>> I see what you meant by the extra variables, so I've fixed that so the
>> original flags aren't needed with recursion. Also updated it to not
>> print the entering command if there is only a post-order command.
>>
>> Examples:
>>
>> $ git submodule foreach --recursive --post-order 'echo Goodbye' "echo \"'ello\""
>> Entering 'b'
>> 'ello
>> Entering 'b/d'
>> 'ello
>> Leaving 'b/d'
>> Goodbye
>> Leaving 'b'
>> Goodbye
>> Entering 'c'
>> 'ello
>> Leaving 'c'
>> Goodbye
>>
>> $ git submodule foreach --recursive --post-order :
>> Leaving 'b/d'
>> Leaving 'b'
>> Leaving 'c'
>>
>> git-submodule.sh | 31 ++++++++++++++++++++++++++-----
>> 1 file changed, 26 insertions(+), 5 deletions(-)
>>
>> diff --git a/git-submodule.sh b/git-submodule.sh
>> index 79bfaac..e08a724 100755
>> --- a/git-submodule.sh
>> +++ b/git-submodule.sh
>> @@ -11,7 +11,7 @@ USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <re
>> or: $dashless [--quiet] deinit [-f|--force] [--] <path>...
>> or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
>> or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
>> - or: $dashless [--quiet] foreach [--recursive] <command>
>> + or: $dashless [--quiet] foreach [--recursive] [--post-order <command>] <command>
>> or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
>> OPTIONS_SPEC=
>> . git-sh-setup
>> @@ -449,6 +449,15 @@ cmd_foreach()
>> --recursive)
>> recursive=1
>> ;;
>> + --post-order)
>> + test "$#" = "1" && usage
>> + post_order="$2"
>> + shift
>> + ;;
>> + --post-order=*)
>> + # Will skip empty commands
>> + post_order=${1#*=}
>> + ;;
>> -*)
>> usage
>> ;;
>> @@ -471,7 +480,9 @@ cmd_foreach()
>> die_if_unmatched "$mode"
>> if test -e "$sm_path"/.git
>> then
>> - say "$(eval_gettext "Entering '\$prefix\$sm_path'")"
>> + enter_msg="$(eval_gettext "Entering '\$prefix\$sm_path'")"
>> + leave_msg="$(eval_gettext "Leaving '\$prefix\$sm_path'")"
>> + die_msg="$(eval_gettext "Stopping at '\$sm_path'; script returned non-zero status.")"
>> name=$(module_name "$sm_path")
>> (
>> prefix="$prefix$sm_path/"
>> @@ -479,13 +490,23 @@ cmd_foreach()
>> # we make $path available to scripts ...
>> path=$sm_path
>> cd "$sm_path" &&
>> - eval "$@" &&
>> + if test $# -gt 0 -o -z "$post_order"
>> + then
>> + say "$enter_msg" &&
>> + eval "$@" || die "$die_msg"
>> + fi &&
>> if test -n "$recursive"
>> then
>> - cmd_foreach "--recursive" "$@"
>> + # subshell will use parent-scoped values
>> + cmd_foreach "$@"
>> + fi &&
>> + if test -n "$post_order"
>> + then
>> + say "$leave_msg" &&
>> + eval "$post_order" || die "$die_msg"
>> fi
>> ) <&3 3<&- ||
>> - die "$(eval_gettext "Stopping at '\$sm_path'; script returned non-zero status.")"
>> + die "$die_msg"
>> fi
>> done
>> }
>> --
>> 1.8.2.1.390.gd4ee029
>>
>
next prev parent reply other threads:[~2013-04-13 4:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 8:41 [PATCH/RFC] Changing submodule foreach --recursive to be depth-first, --parent option to execute command in supermodule as well Eric Cousineau
2013-03-04 22:15 ` Jens Lehmann
2013-03-04 23:00 ` Junio C Hamano
2013-03-05 5:37 ` Eric Cousineau
2013-03-05 7:59 ` Heiko Voigt
2013-03-05 16:09 ` Junio C Hamano
2013-03-05 16:42 ` Eric Cousineau
2013-03-05 18:34 ` Junio C Hamano
2013-03-05 20:51 ` Jens Lehmann
2013-03-05 21:17 ` Phil Hord
2013-03-09 18:18 ` Jens Lehmann
2013-03-11 16:46 ` Heiko Voigt
2013-03-12 16:01 ` Phil Hord
2013-03-14 6:30 ` Eric Cousineau
2013-03-18 21:25 ` Jens Lehmann
2013-03-26 4:03 ` Eric Cousineau
2013-04-02 20:14 ` Jens Lehmann
2013-04-13 4:04 ` [PATCH] submodule foreach: Added in --post-order=<command> and adjusted code per Jens Lehmann's suggestions eacousineau
[not found] ` <CA+aSAWuK9Yhvx-vO1fUteq-K=xOPgxkyeWeHG3UwZuDHsxLzAw@mail.gmail.com>
2013-04-13 4:11 ` Eric Cousineau [this message]
2013-04-14 18:52 ` Jens Lehmann
2013-03-18 21:10 ` [PATCH/RFC] Changing submodule foreach --recursive to be depth-first, --parent option to execute command in supermodule as well Jens Lehmann
2013-03-26 3:56 ` Eric Cousineau
2013-03-26 4:36 ` Eric Cousineau
2013-03-26 5:23 ` Junio C Hamano
2013-03-26 5:25 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+aSAWviVWd3+89Wpv-1_6BSL=aN-u+60_oDXcyCG03enBmGTg@mail.gmail.com' \
--to=eacousineau@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).