@@ -250,7 +250,6 @@ Use -f if you really want to add it." &&
250250 url=" $repo "
251251 ;;
252252 esac
253- git config submodule." $path " .url " $url "
254253 else
255254
256255 module_clone " $path " " $realrepo " " $reference " || exit
@@ -264,6 +263,7 @@ Use -f if you really want to add it." &&
264263 esac
265264 ) || die " $( eval_gettext " Unable to checkout submodule '\$ path'" ) "
266265 fi
266+ git config submodule." $path " .url " $url "
267267
268268 git add $force " $path " ||
269269 die " $( eval_gettext " Failed to add submodule '\$ path'" ) "
@@ -363,25 +363,26 @@ cmd_init()
363363 do
364364 # Skip already registered paths
365365 name=$( module_name " $path " ) || exit
366- url=$( git config submodule." $name " .url)
367- test -z " $url " || continue
368-
369- url=$( git config -f .gitmodules submodule." $name " .url)
370- test -z " $url " &&
371- die " $( eval_gettext " No url found for submodule path '\$ path' in .gitmodules" ) "
372-
373- # Possibly a url relative to parent
374- case " $url " in
375- ./* |../* )
376- url=$( resolve_relative_url " $url " ) || exit
377- ;;
378- esac
379-
380- git config submodule." $name " .url " $url " ||
381- die " $( eval_gettext " Failed to register url for submodule path '\$ path'" ) "
366+ if test -z " $( git config " submodule.$name .url" ) "
367+ then
368+ url=$( git config -f .gitmodules submodule." $name " .url)
369+ test -z " $url " &&
370+ die " $( eval_gettext " No url found for submodule path '\$ path' in .gitmodules" ) "
371+
372+ # Possibly a url relative to parent
373+ case " $url " in
374+ ./* |../* )
375+ url=$( resolve_relative_url " $url " ) || exit
376+ ;;
377+ esac
378+ git config submodule." $name " .url " $url " ||
379+ die " $( eval_gettext " Failed to register url for submodule path '\$ path'" ) "
380+ fi
382381
382+ # Copy "update" setting when it is not set yet
383383 upd=" $( git config -f .gitmodules submodule." $name " .update) "
384384 test -z " $upd " ||
385+ test -n " $( git config submodule." $name " .update) " ||
385386 git config submodule." $name " .update " $upd " ||
386387 die " $( eval_gettext " Failed to register update mode for submodule path '\$ path'" ) "
387388
@@ -925,17 +926,20 @@ cmd_sync()
925926 ;;
926927 esac
927928
928- say " $( eval_gettext " Synchronizing submodule url for '\$ name'" ) "
929- git config submodule." $name " .url " $url "
930-
931- if test -e " $path " /.git
929+ if git config " submodule.$name .url" > /dev/null 2> /dev/null
932930 then
933- (
934- clear_local_git_env
935- cd " $path "
936- remote=$( get_default_remote)
937- git config remote." $remote " .url " $url "
938- )
931+ say " $( eval_gettext " Synchronizing submodule url for '\$ name'" ) "
932+ git config submodule." $name " .url " $url "
933+
934+ if test -e " $path " /.git
935+ then
936+ (
937+ clear_local_git_env
938+ cd " $path "
939+ remote=$( get_default_remote)
940+ git config remote." $remote " .url " $url "
941+ )
942+ fi
939943 fi
940944 done
941945}
0 commit comments