Skip to content

Commit 82f49f2

Browse files
phordpeff
authored andcommitted
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 <[email protected]> Acked-By: Jens Lehmann <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 8c7a786 commit 82f49f2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

git-submodule.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ USAGE="[--quiet] add [-b branch] [-f|--force] [--reference <repository>] [--] <r
1111
or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
1212
or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
1313
or: $dashless [--quiet] foreach [--recursive] <command>
14-
or: $dashless [--quiet] sync [--] [<path>...]"
14+
or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
1515
OPTIONS_SPEC=
1616
. git-sh-setup
1717
. git-sh-i18n
@@ -1010,6 +1010,10 @@ cmd_sync()
10101010
GIT_QUIET=1
10111011
shift
10121012
;;
1013+
--recursive)
1014+
recursive=1
1015+
shift
1016+
;;
10131017
--)
10141018
shift
10151019
break
@@ -1051,7 +1055,7 @@ cmd_sync()
10511055

10521056
if git config "submodule.$name.url" >/dev/null 2>/dev/null
10531057
then
1054-
say "$(eval_gettext "Synchronizing submodule url for '\$name'")"
1058+
say "$(eval_gettext "Synchronizing submodule url for '\$prefix\$sm_path'")"
10551059
git config submodule."$name".url "$super_config_url"
10561060

10571061
if test -e "$sm_path"/.git
@@ -1061,6 +1065,12 @@ cmd_sync()
10611065
cd "$sm_path"
10621066
remote=$(get_default_remote)
10631067
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
10641074
)
10651075
fi
10661076
fi

0 commit comments

Comments
 (0)