Skip to content

Commit 1d5bec8

Browse files
jherlandgitster
authored andcommitted
git submodule: Cleanup usage string and add option parsing to cmd_foreach()
Signed-off-by: Johan Herland <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e7f2aa commit 1d5bec8

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

git-submodule.sh

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
#
55
# Copyright (c) 2007 Lars Hjemli
66

7-
USAGE="[--quiet] [--cached] \
8-
[add [-b branch] <repo> <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [--rebase|--merge]|summary [-n|--summary-limit <n>] [<commit>]] \
9-
[--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
7+
dashless=$(basename "$0" | sed -e 's/-/ /')
8+
USAGE="[--quiet] add [-b branch] [--reference <repository>] [--] <repository> <path>
9+
or: $dashless [--quiet] status [--cached] [--] [<path>...]
10+
or: $dashless [--quiet] init [--] [<path>...]
11+
or: $dashless [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--] [<path>...]
12+
or: $dashless [--quiet] summary [--cached] [--summary-limit <n>] [commit] [--] [<path>...]
13+
or: $dashless [--quiet] foreach <command>
14+
or: $dashless [--quiet] sync [--] [<path>...]"
1015
OPTIONS_SPEC=
1116
. git-sh-setup
1217
. git-parse-remote
@@ -237,6 +242,23 @@ cmd_add()
237242
#
238243
cmd_foreach()
239244
{
245+
# parse $args after "submodule ... foreach".
246+
while test $# -ne 0
247+
do
248+
case "$1" in
249+
-q|--quiet)
250+
GIT_QUIET=1
251+
;;
252+
-*)
253+
usage
254+
;;
255+
*)
256+
break
257+
;;
258+
esac
259+
shift
260+
done
261+
240262
module_list |
241263
while read mode sha1 stage path
242264
do

0 commit comments

Comments
 (0)