Teach --recursive to submodule sync

The submodule sync command was somehow left out when --recursive was added to the other submodule commands. Teach sync to handle the --recursive switch by recursing when we're in a submodule we are sync'ing. Change the report during sync to show submodule-path instead of submodule-name to be consistent with the other submodule commands and to help recursed paths make sense. Signed-off-by: Phil Hord <hordp@cisco.com> Acked-By: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Jeff King <peff@peff.net>

Phil Hord committed Oct 26, 2012 at 15:44 UTC 82f49f294c5ee58aff33dfd469bbd5c0d083e314
1 file changed +12 -2
git-submodule.sh
+12 -2
@@ -11,7 +11,7 @@ USAGE="[--quiet] add [-b branch] [-f|--force] [--reference <repository>] [--] <r
11 or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
12 or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
13 or: $dashless [--quiet] foreach [--recursive] <command>
14 - or: $dashless [--quiet] sync [--] [<path>...]"
14 + or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
15 OPTIONS_SPEC=
16 . git-sh-setup
17 . git-sh-i18n
@@ -1010,6 +1010,10 @@ cmd_sync()
1010 GIT_QUIET=1
1011 shift
1012 ;;
1013 + --recursive)
1014 + recursive=1
1015 + shift
1016 + ;;
1017 --)
1018 shift
1019 break
@@ -1051,7 +1055,7 @@ cmd_sync()
1055
1056 if git config "submodule.$name.url" >/dev/null 2>/dev/null
1057 then
1054 - say "$(eval_gettext "Synchronizing submodule url for '\$name'")"
1058 + say "$(eval_gettext "Synchronizing submodule url for '\$prefix\$sm_path'")"
1059 git config submodule."$name".url "$super_config_url"
1060
1061 if test -e "$sm_path"/.git
@@ -1061,6 +1065,12 @@ cmd_sync()
1065 cd "$sm_path"
1066 remote=$(get_default_remote)
1067 git config remote."$remote".url "$sub_origin_url"
1068 +
1069 + if test -n "$recursive"
1070 + then
1071 + prefix="$prefix$sm_path/"
1072 + eval cmd_sync
1073 + fi
1074 )
1075 fi
1076 fi