From b045c16cffe6eb86c157a6c7397166a46e147442 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 2 Dec 2012 10:24:46 -0500 Subject: [PATCH] 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 --- git-submodule.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- 2.26.2