@matheusbsbs / matheus-bagliano / commits / c2f939170c
Fork 0

git-submodule - register submodule URL if adding in place

When adding a new submodule in place, meaning the user created the submodule as a git repo in the superproject's tree first, we don't go through "git submodule init" to register the module. Thus, the submodule's origin repository URL is not stored in .git/config, and no subsequent submodule operation will ever do so. In this case, assume the URL the user supplies to "submodule add" is the one that should be registered, and do so. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mark Levedahl committed Jul 9, 2008 at 21:05 UTC c2f939170c65173076bbd752bb3c764536b3b09b
1 file changed +10
git-submodule.sh
+10
@@ -172,6 +172,16 @@ cmd_add()
172 else
173 die "'$path' already exists and is not a valid git repo"
174 fi
175 +
176 + case "$repo" in
177 + ./*|../*)
178 + url=$(resolve_relative_url "$repo") || exit
179 + ;;
180 + *)
181 + url="$repo"
182 + ;;
183 + esac
184 + git config submodule."$path".url "$url"
185 else
186
187 module_clone "$path" "$realrepo" || exit