From: W. Trevor King Date: Sat, 1 Dec 2012 17:11:45 +0000 (-0500) Subject: submodule sync: add --local and --no-local X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=db34fa98d491123bb541a1f5471728a0a523fb98;p=git.git submodule sync: add --local and --no-local These control whether or not the submodule..url setting is set in the superproject config. With --local, the setting is always set. With --no-local, it is only set if another value is already set. Use $ git submodule sync --local to forcibly populate the local config, and $ git submodule sync --no-local to only update the existing local configuration. Default to --local for compatibility with earlier versions of Git. Signed-off-by: W. Trevor King --- diff --git a/git-submodule.sh b/git-submodule.sh index 7a467c49b..dd00adb08 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -11,7 +11,7 @@ USAGE="[--quiet] add [-b branch] [-f|--force] [--reference ] [--] ] [--merge] [--recursive] [--] [...] or: $dashless [--quiet] summary [--cached|--files] [--summary-limit ] [commit] [--] [...] or: $dashless [--quiet] foreach [--recursive] - or: $dashless [--quiet] sync [--] [...]" + or: $dashless [--quiet] sync [--local] [--no-local] [--] [...]" OPTIONS_SPEC= . git-sh-setup . git-sh-i18n @@ -28,6 +28,7 @@ init= files= nofetch= update= +local= prefix= # @@ -1147,6 +1148,7 @@ cmd_status() # cmd_sync() { + local=1 while test $# -ne 0 do case "$1" in @@ -1154,6 +1156,14 @@ cmd_sync() GIT_QUIET=1 shift ;; + --local) + local=1 + shift + ;; + --no-local) + local= + shift + ;; --) shift break @@ -1172,26 +1182,26 @@ cmd_sync() do die_if_unmatched "$mode" name=$(module_name "$sm_path") - # .gitmodules-style (unresolved) url for the submodule origin repo - super_config_url=$(get_submodule_config "$name" url) - # path from submodule work tree to submodule origin repo - sub_origin_url=$(get_submodule_url "$name" "$sm_path") - if git config "submodule.$name.url" >/dev/null 2>/dev/null + if test -n "$local" || git config "submodule.$name.url" >/dev/null 2>/dev/null then + # path from supermodule work tree to submodule origin repo + super_config_url=$(get_submodule_url_from_gitmodules "$name") say "$(eval_gettext "Synchronizing submodule url for '\$name' (superproject config)")" git config submodule."$name".url "$super_config_url" fi if test -e "$sm_path"/.git then - say "$(eval_gettext "Synchronizing submodule url for '\$name' (subproject config)")" - ( - clear_local_git_env - cd "$sm_path" - remote=$(get_default_remote) - git config remote."$remote".url "$sub_origin_url" - ) + # path from submodule work tree to submodule origin repo + sub_origin_url=$(get_submodule_url "$name" "$sm_path") + say "$(eval_gettext "Synchronizing submodule url for '\$name' (subproject config)")" + ( + clear_local_git_env + cd "$sm_path" + remote=$(get_default_remote) + git config remote."$remote".url "$sub_origin_url" + ) fi done }