summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2009-08-19 01:45:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-08-19 05:59:12 (GMT)
commitb13fd5c1a2bd450cdf7b853e0c4861f361882a18 (patch)
tree018a5a1d768bc24e4a84c6ad32da32d202adf3df /git-submodule.sh
parent15fc56a853648c60697df691c5cd8a11ad718611 (diff)
downloadgit-b13fd5c1a2bd450cdf7b853e0c4861f361882a18.zip
git-b13fd5c1a2bd450cdf7b853e0c4861f361882a18.tar.gz
git-b13fd5c1a2bd450cdf7b853e0c4861f361882a18.tar.bz2
git submodule update: Introduce --recursive to update nested submodules
In very large and hierarchically structured projects, one may encounter nested submodules. In these situations, it is valuable to not only update the submodules in the current repo (which is what is currently done by 'git submodule update'), but also to operate on all submodules at all levels (i.e. recursing into nested submodules as well). This patch teaches the new --recursive option to the 'git submodule update' command. The patch also includes documentation and selftests. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh13
1 files changed, 12 insertions, 1 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index c501b7e..d8b98ff 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -8,7 +8,7 @@ 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] update [--init] [-N|--no-fetch] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
or: $dashless [--quiet] summary [--cached] [--summary-limit <n>] [commit] [--] [<path>...]
or: $dashless [--quiet] foreach [--recursive] <command>
or: $dashless [--quiet] sync [--] [<path>...]"
@@ -352,6 +352,7 @@ cmd_init()
cmd_update()
{
# parse $args after "submodule ... update".
+ orig_args="$@"
while test $# -ne 0
do
case "$1" in
@@ -384,6 +385,10 @@ cmd_update()
shift
update="merge"
;;
+ --recursive)
+ shift
+ recursive=1
+ ;;
--)
shift
break
@@ -470,6 +475,12 @@ cmd_update()
die "Unable to $action '$sha1' in submodule path '$path'"
say "Submodule path '$path': $msg '$sha1'"
fi
+
+ if test -n "$recursive"
+ then
+ (unset GIT_DIR; cd "$path" && cmd_update $orig_args) ||
+ die "Failed to recurse into submodule path '$path'"
+ fi
done
}