diff options
| author | Junio C Hamano <gitster@pobox.com> | 2008-08-20 23:42:33 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2008-08-20 23:42:33 -0700 |
| commit | 5630feaf370e15c01ef8a6aa469bfd656c1d1cd7 (patch) | |
| tree | 32b710660b7ee69cbeba3b0caca16769bcad50a7 /git-submodule.sh | |
| parent | 299c3714d433b0427a49a10977cc021c52f0aeb8 (diff) | |
| parent | 19a31f9c1a6b18abd8a7f20d616516afca36a6a3 (diff) | |
| download | git-5630feaf370e15c01ef8a6aa469bfd656c1d1cd7.tar.xz | |
Merge branch 'ml/submodule-foreach'
* ml/submodule-foreach:
git-submodule - Add 'foreach' subcommand
Diffstat (limited to 'git-submodule.sh')
| -rwxr-xr-x | git-submodule.sh | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index b40f876a2c..2d57d60458 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -6,7 +6,7 @@ USAGE="[--quiet] [--cached] \ [add <repo> [-b branch] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \ -[--] [<path>...]" +[--] [<path>...]|[foreach <command>]" OPTIONS_SPEC= . git-sh-setup require_work_tree @@ -199,6 +199,26 @@ cmd_add() } # +# Execute an arbitrary command sequence in each checked out +# submodule +# +# $@ = command to execute +# +cmd_foreach() +{ + git ls-files --stage | grep '^160000 ' | + while read mode sha1 stage path + do + if test -e "$path"/.git + then + say "Entering '$path'" + (cd "$path" && eval "$@") || + die "Stopping at '$path'; script returned non-zero status." + fi + done +} + +# # Register submodules in .git/config # # $@ = requested paths (default to all) @@ -583,7 +603,7 @@ cmd_status() while test $# != 0 && test -z "$command" do case "$1" in - add | init | update | status | summary) + add | foreach | init | update | status | summary) command=$1 ;; -q|--quiet) |
