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

[PATCH v4] submodule: add --recursive parameter to update command

From
FFFabian Franz <git@fabian-franz.de>
Date
Jan 10, 2009, 02:10 UTC
Message-ID
<1231553410-7541-5-git-send-email-git@fabian-franz.de>
In-Reply-To
<1231553410-7541-4-git-send-email-git@fabian-franz.de>

If --recursive is specified on update, then recursively check for .gitmodules in each updated submodule and run init and update commands. The update command is run with the same parameters as the original update command with the exception of the path.

Signed-off-by: Fabian Franz <git@fabian-franz.de>
---
 Documentation/git-submodule.txt |    8 ++++++++
 git-submodule.sh                |   17 ++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index fbb18ee..c9adc43 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -188,6 +188,14 @@ OPTIONS
 	This option is only valid for the update command.
 	Don't fetch new objects from the remote site.
 
+-r::
+--recursive::
+	This option is only valid for the update command.
+	Recursively check for .gitmodules in each updated submodule and run
+	init and update commands. The update command is run with the same
+	parameters as the original update command with the exception of the
+	path.
+
 -u::
 --use-gitmodules::
 	This option is only valid for the update command.
diff --git a/git-submodule.sh b/git-submodule.sh
index 54b59b2..8bb00b7 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -5,7 +5,7 @@
 # Copyright (c) 2007 Lars Hjemli
 
 USAGE="[--quiet] [--cached] \
-[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [-u|--use-gitmodules]|summary [-n|--summary-limit <n>] [<commit>]] \
+[add <repo> [-b branch] [--track|-t <branch>] <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [-r|--recursive] [-u|--use-gitmodules]|summary [-n|--summary-limit <n>] [<commit>]] \
 [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
 OPTIONS_SPEC=
 . git-sh-setup
@@ -19,6 +19,7 @@ cached=
 track=
 nofetch=
 usegitmodules=
+recursive=
 
 #
 # print stuff on stdout unless -q was specified
@@ -319,6 +320,10 @@ cmd_update()
 			shift
 			nofetch=1
 			;;
+		-r|--recursive)
+			shift
+			recursive=1
+			;;
 		-u|--use-gitmodules)
 			shift
 			usegitmodules=1
@@ -445,6 +450,16 @@ cmd_update()
 
 			say "Submodule path '$path': checked out '$sha1'${track:+ ($track)}"
 		fi
+		if test -n "$recursive" -a -f "$path/.gitmodules"
+		then
+			PARAMS="${quiet:+-q} ${nofetch:+--no-fetch} ${recursive:+-r} ${usegitmodules:+-u}"
+			say "Entering submodule path '$path'"
+			(unset GIT_DIR; cd "$path" &&
+				  git-submodule init &&
+				  git-submodule update $PARAMS) ||
+			die "Unable to run 'git-submodule update $PARAMS' in submodule path '$path'"
+			say "Leaving submodule path '$path'"
+		fi
 	done
 }
 
-- 
1.5.3.6
Previous: Fabian FranzNext: Junio C Hamano
Message 5 of 9 in “submodule: allow tracking of the newest revision of a branch in a submodule”
  1. submodule: allow tracking of the newest revision of a branch in a submoduleFabian Franz, Jan 10, 2009
  2. submodule: add --no-fetch parameter to update commandFabian Franz, Jan 10, 2009
  3. submodule: add --use-gitmodules parameter to update commandFabian Franz, Jan 10, 2009
  4. submodule: add +<branch> syntax for track to allow automatic pulling.Fabian Franz, Jan 10, 2009
  5. submodule: add --recursive parameter to update commandFabian Franz, Jan 10, 2009
  6. Junio C HamanoJan 11, 2009
  7. Nanako ShiraishiJan 11, 2009
  8. Nanako ShiraishiJan 11, 2009
  9. Johannes SchindelinJan 10, 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.