{"thread":{"id":"25932","subject":"[PATCH 1/1] git-submodule.sh: fix relative paths with ssh urls","startedAt":"2010-12-03T02:53:41Z","lastAt":"2010-12-03T02:53:41Z","messageCount":1,"participants":["Russell Yanofsky"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"157170","messageId":"1291344821-20964-1-git-send-email-russ@yanofsky.org","threadId":"25932","inReplyTo":null,"subject":"[PATCH 1/1] git-submodule.sh: fix relative paths with ssh urls","fromName":"Russell Yanofsky","fromEmail":"russ@yanofsky.org","sentAt":"2010-12-03T02:53:41Z","receivedAt":"2010-12-03T02:53:41Z","isPatch":true,"sender":{"key":"russ@yanofsky.org","avatar":null},"body":"Fix handling of submodule urls starting with ../ when the remote url is\nan scp-style URL with the format user@host.xz:repo.git. For example, if\nthe remote url is user@host.xz:repo.git and the submodule URL is\n../submodule.git, the combined default URL will now be\nuser@host.xz:submodule.git instead of\nuser@host.xz:repo.git/submodule.git.\n---\n git-submodule.sh |   16 ++++++++++++++--\n 1 files changed, 14 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex c291eed..533cf5d 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -36,13 +36,25 @@ resolve_relative_url ()\n \tremoteurl=$(git config \"remote.$remote.url\") ||\n \t\tdie \"remote ($remote) does not have a url defined in .git/config\"\n \turl=\"$1\"\n+\tsep=\"/\"\n \tremoteurl=${remoteurl%/}\n \twhile test -n \"$url\"\n \tdo\n \t\tcase \"$url\" in\n \t\t../*)\n \t\t\turl=\"${url#../}\"\n-\t\t\tremoteurl=\"${remoteurl%/*}\"\n+\t\t\tremoteparent=\"${remoteurl%/*}\"\n+\t\t\tif test \"$remoteparent\" != \"$remoteurl\"\n+\t\t\tthen\n+\t\t\t\tremoteurl=\"$remoteparent\"\n+\t\t\telse\n+\t\t\t\tremoteparent=\"${remoteurl%:*}\"\n+\t\t\t\tif test \"$remoteparent\" != \"$remoteurl\"\n+\t\t\t\tthen\n+\t\t\t\t\tremoteurl=\"$remoteparent\"\n+\t\t\t\t\tsep=\":\"\n+\t\t\t\tfi\n+\t\t\tfi\n \t\t\t;;\n \t\t./*)\n \t\t\turl=\"${url#./}\"\n@@ -51,7 +63,7 @@ resolve_relative_url ()\n \t\t\tbreak;;\n \t\tesac\n \tdone\n-\techo \"$remoteurl/${url%/}\"\n+\techo \"$remoteurl$sep${url%/}\"\n }\n \n #\n-- \n1.7.3.2\n"}]}