From: Junio C Hamano Date: Tue, 19 Jul 2011 16:45:37 +0000 (-0700) Subject: Merge branch 'jc/submodule-sync-no-auto-vivify' X-Git-Tag: v1.7.7-rc0~87 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0591c0a5be7d58dfe2c69c8a81b2cebbb0337320;p=git.git Merge branch 'jc/submodule-sync-no-auto-vivify' * jc/submodule-sync-no-auto-vivify: submodule add: always initialize .git/config entry submodule sync: do not auto-vivify uninteresting submodule Conflicts: git-submodule.sh --- 0591c0a5be7d58dfe2c69c8a81b2cebbb0337320 diff --cc git-submodule.sh index 87c9452c8,ec6178ee9..3daa0c834 --- a/git-submodule.sh +++ b/git-submodule.sh @@@ -260,13 -240,14 +259,14 @@@ Use -f if you really want to add it." & # ash fails to wordsplit ${branch:+-b "$branch"...} case "$branch" in '') git checkout -f -q ;; - ?*) git checkout -f -q -b "$branch" "origin/$branch" ;; + ?*) git checkout -f -q -B "$branch" "origin/$branch" ;; esac - ) || die "Unable to checkout submodule '$path'" + ) || die "$(eval_gettext "Unable to checkout submodule '\$path'")" fi + git config submodule."$path".url "$url" git add $force "$path" || - die "Failed to add submodule '$path'" + die "$(eval_gettext "Failed to add submodule '\$path'")" git config -f .gitmodules submodule."$path".path "$path" && git config -f .gitmodules submodule."$path".url "$repo" && @@@ -363,29 -340,30 +363,30 @@@ cmd_init( do # Skip already registered paths name=$(module_name "$path") || exit - url=$(git config submodule."$name".url) - test -z "$url" || continue - - url=$(git config -f .gitmodules submodule."$name".url) - test -z "$url" && - die "$(eval_gettext "No url found for submodule path '\$path' in .gitmodules")" - - # Possibly a url relative to parent - case "$url" in - ./*|../*) - url=$(resolve_relative_url "$url") || exit - ;; - esac - - git config submodule."$name".url "$url" || - die "$(eval_gettext "Failed to register url for submodule path '\$path'")" + if test -z "$(git config "submodule.$name.url")" + then + url=$(git config -f .gitmodules submodule."$name".url) + test -z "$url" && - die "No url found for submodule path '$path' in .gitmodules" ++ die "$(eval_gettext "No url found for submodule path '\$path' in .gitmodules")" + + # Possibly a url relative to parent + case "$url" in + ./*|../*) + url=$(resolve_relative_url "$url") || exit + ;; + esac + git config submodule."$name".url "$url" || - die "Failed to register url for submodule path '$path'" ++ die "$(eval_gettext "Failed to register url for submodule path '\$path'")" + fi + # Copy "update" setting when it is not set yet upd="$(git config -f .gitmodules submodule."$name".update)" test -z "$upd" || + test -n "$(git config submodule."$name".update)" || git config submodule."$name".update "$upd" || - die "Failed to register update mode for submodule path '$path'" + die "$(eval_gettext "Failed to register update mode for submodule path '\$path'")" - say "Submodule '$name' ($url) registered for path '$path'" + say "$(eval_gettext "Submodule '\$name' (\$url) registered for path '\$path'")" done } @@@ -925,17 -837,20 +926,20 @@@ cmd_sync( ;; esac - say "$(eval_gettext "Synchronizing submodule url for '\$name'")" - git config submodule."$name".url "$url" - - if test -e "$path"/.git + if git config "submodule.$name.url" >/dev/null 2>/dev/null then - ( - clear_local_git_env - cd "$path" - remote=$(get_default_remote) - git config remote."$remote".url "$url" - ) - say "Synchronizing submodule url for '$name'" ++ say "$(eval_gettext "Synchronizing submodule url for '\$name'")" + git config submodule."$name".url "$url" + + if test -e "$path"/.git + then + ( + clear_local_git_env + cd "$path" + remote=$(get_default_remote) + git config remote."$remote".url "$url" + ) + fi fi done }