git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH 1/6] git submodule: Cleanup usage string and add option parsing to cmd_foreach()

From
Johan Herland <johan@herland.net>
Date
Aug 19, 2009, 01:45 UTC
Message-ID
<1250646324-961-2-git-send-email-johan@herland.net>
In-Reply-To
<1250646324-961-1-git-send-email-johan@herland.net>
Signed-off-by: Johan Herland <johan@herland.net>
---
 git-submodule.sh |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 9bdd6ea..c58eca4 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -4,9 +4,14 @@
 #
 # Copyright (c) 2007 Lars Hjemli
 
-USAGE="[--quiet] [--cached|--files] \
-[add [-b branch] <repo> <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [--rebase|--merge]|summary [-n|--summary-limit <n>] [<commit>]] \
-[--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
+dashless=$(basename "$0" | sed -e 's/-/ /')
+USAGE="[--quiet] add [-b branch] [--reference <repository>] [--] <repository> <path>
+   or: $dashless [--quiet] status [--cached] [--] [<path>...]
+   or: $dashless [--quiet] init [--] [<path>...]
+   or: $dashless [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--] [<path>...]
+   or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
+   or: $dashless [--quiet] foreach <command>
+   or: $dashless [--quiet] sync [--] [<path>...]"
 OPTIONS_SPEC=
 . git-sh-setup
 . git-parse-remote
@@ -238,6 +243,23 @@ cmd_add()
 #
 cmd_foreach()
 {
+	# parse $args after "submodule ... foreach".
+	while test $# -ne 0
+	do
+		case "$1" in
+		-q|--quiet)
+			GIT_QUIET=1
+			;;
+		-*)
+			usage
+			;;
+		*)
+			break
+			;;
+		esac
+		shift
+	done
+
 	module_list |
 	while read mode sha1 stage path
 	do
-- 
1.6.4.304.g1365c.dirty
Previous: Johan HerlandNext: Johan Herland
Message 2 of 8 in “Git submodule: 'foreach' enhancements and nested submodule handling”
  1. 0/6 Git submodule: 'foreach' enhancements and nested submodule handlingJohan Herland, Aug 19, 2009
  2. 1/6 git submodule: Cleanup usage string and add option parsing to cmd_foreach()Johan Herland, Aug 19, 2009
  3. 2/6 Add selftest for 'git submodule foreach'Johan Herland, Aug 19, 2009
  4. 3/6 git submodule foreach: Provide access to submodule name, as '$name'Johan Herland, Aug 19, 2009
  5. 4/6 git submodule foreach: Add --recursive to recurse into nested submodulesJohan Herland, Aug 19, 2009
  6. 5/6 git submodule update: Introduce --recursive to update nested submodulesJohan Herland, Aug 19, 2009
  7. 6/6 git submodule status: Add --recursive to recurse into nested submodulesJohan Herland, Aug 19, 2009
  8. 7/6 git clone: Add --recursive to automatically checkout (nested) submodulesJohan Herland, Aug 19, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.