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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux