From: W. Trevor King Date: Sun, 2 Dec 2012 15:24:46 +0000 (-0500) Subject: submodule add: configure existing submodule url if not set X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b045c16cffe6eb86c157a6c7397166a46e147442;p=git.git submodule add: configure existing submodule url if not set Note that relative repository arguments passed to $ git submodule add [] are expanded relative to the superproject's remote URL, not relative to the current working directory. Signed-off-by: W. Trevor King --- diff --git a/git-submodule.sh b/git-submodule.sh index dd00adb08..8b47db6a3 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -496,7 +496,18 @@ Use -f if you really want to add it." >&2 else die "$(eval_gettext "'\$sm_path' already exists and is not a valid git repo")" fi - + # if the submodule's remote URL is not set, set it + up_path=$(get_up_path "$sm_path") + sub_url=$(join_urls "$up_path" "$realrepo") + ( + clear_local_git_env + cd "$sm_path" && + remote=$(get_default_remote) && + if ! git config remote."$remote".url > /dev/null 2>/dev/null + then + git config remote."$remote".url "$sub_url" + fi + ) || die "$(eval_gettext "Unable to configure submodule remote '\$sm_path'")" else module_clone "$sm_path" "$realrepo" "$reference" || exit