aboutsummaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorMark Levedahl <mlevedahl@gmail.com>2008-08-21 19:54:01 -0400
committerJunio C Hamano <gitster@pobox.com>2008-08-21 23:14:09 -0700
commit99b120af7081ea9eb03a5f2a605d2bab771cf634 (patch)
treeafe7bbebcaf9d66b1e2a2acae840247f7be70963 /git-submodule.sh
parent7c695619868d0b867c87b0bb83303e058e010ac5 (diff)
downloadgit-99b120af7081ea9eb03a5f2a605d2bab771cf634.tar.gz
git-99b120af7081ea9eb03a5f2a605d2bab771cf634.tar.xz
git-submodule.sh - Remove trailing / from URL if found
git clone does not complain if a trailing '/' is included in the origin URL, but doing so causes resolution of a submodule's URL relative to the superproject to fail. Trailing /'s are likely when cloning locally using tab-completion, so the slash may appear in either superproject or submodule URL. So, ignore the trailing slash if it already exists in the superproject's URL, and don't record one for the submodule (which could itself have submodules...). The problem I'm trying to fix is that a number of folks have superprojects checked out where the recorded origin URL has a trailing /, and a submodule has its origin in a directory sitting right next to the superproject on the server. Thus, we have: superproject url = server:/public/super submodoule url = server:/public/sub1 However, in the checked out superproject's .git/config [remote "origin"] url = server:/public/super/ and for similar reasons, the submodule has its URL recorded in .gitmodules as [submodule "sub"] path = submodule1 url = ../sub1/ resolve_relative_url gets the submodule's recorded url as $1, which the caller retrieved from .gitmodules, and retrieves the superprojects origin from .git/config. So in this case resolve_relative_url has that: url = ../sub1/ remoteurl = server:/public/super/ So, without any patch, resolve_relative_url computes the submodule's URL as: server:/public/super/sub1/ rather than server:/public/sub1 In summary, it is essential that resolve_relative_url strip the trailing / from the superproject's url before starting, and beneficial if it assures that the result does not contain a trailing / as the submodule may itself also be a superproject. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index e4c31fb7d..46d75aba3 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -35,7 +35,8 @@ resolve_relative_url ()
remote="${remote:-origin}"
remoteurl=$(git config "remote.$remote.url") ||
die "remote ($remote) does not have a url defined in .git/config"
- url="${1%/}"
+ url="$1"
+ remoteurl=${remoteurl%/}
while test -n "$url"
do
case "$url" in
@@ -50,7 +51,7 @@ resolve_relative_url ()
break;;
esac
done
- echo "$remoteurl/$url"
+ echo "$remoteurl/${url%/}"
}
#