{"thread":{"id":"30690","subject":"[PATCH v8 0/4] submodule: improve support for relative superproject origin URLs","startedAt":"2012-06-03T09:46:46Z","lastAt":"2012-06-06T11:09:59Z","messageCount":10,"participants":["Jon Seymour","Junio C Hamano","Jens Lehmann"],"isPatch":true,"patchVersion":8,"patchTotal":4},"messages":[{"id":"192743","messageId":"1338716810-9881-1-git-send-email-jon.seymour@gmail.com","threadId":"30690","inReplyTo":null,"subject":"[PATCH v8 0/4] submodule: improve support for relative superproject origin URLs","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2012-06-03T09:46:46Z","receivedAt":"2012-06-03T09:46:46Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This series improves handling by 'git submodule' of relative superproject origin URLs. \n\nCurrently, 'git submodule':\n\n* incorrectly configures origin URL for submodules with a path that is relative to\nthe work tree of the superproject when the configured path needs to be relative \nto the work tree of the submodule\n\n* unnecessarily fails with an error if the superproject origin URL is of the form: foo\n\nThis series corrects these problems for paths like the following:\n  foo\n  foo/bar\n  ./foo\n  ./foo/bar\n  ../foo\n  ../foo/bar\n\nIt does not change current behaviour for URLs that begin with a leading / or contain\na : as such URLs are deemed to be absolute URLs for which no correction is required.\n\nIn addition, this series ensures that relative URLs configured by git submodule do\nnot include a superfluous leading or embedded './'.\n\nThis series differs from v7 by removing the patches dealing incorrect handling \nof greedy submodule URLs (those with too many leading ../'s) and those that deal\nwith improperly normalized superproject origin URLs. These patches may resubmitted\nat a later date.\n\nJon Seymour (4):\n  submodule: additional regression tests for relative URLs\n  submodule: document failure to handle relative superproject origin\n    URLs\n  submodule: fix sync handling of some relative superproject origin\n    URLs\n  submodule: fix handling of superproject origin URLs like foo, ./foo\n    and ./foo/bar\n\n git-submodule.sh           |  65 +++++++++++++++++---\n t/t7400-submodule-basic.sh | 144 ++++++++++++++++++++++++++++++++++++++++++++-\n t/t7403-submodule-sync.sh  |  90 +++++++++++++++++++++++++++-\n 3 files changed, 287 insertions(+), 12 deletions(-)\n\n-- \n1.7.10.2.652.gdffd412\n"},{"id":"192744","messageId":"1338716810-9881-2-git-send-email-jon.seymour@gmail.com","threadId":"30690","inReplyTo":"1338716810-9881-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 1/4] submodule: additional regression tests for relative URLs","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2012-06-03T09:46:47Z","receivedAt":"2012-06-03T09:46:47Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Some additional tests are added to support regression testing of the changes in the\nremainder of the series.\n\nWe also add a pristine copy of .gitmodules in anticipation of this being\nrequired by later tests.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n t/t7400-submodule-basic.sh | 110 +++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 107 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 81827e6..9428c7a 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -483,21 +483,67 @@ test_expect_success 'set up for relative path tests' '\n \t\tgit add sub &&\n \t\tgit config -f .gitmodules submodule.sub.path sub &&\n \t\tgit config -f .gitmodules submodule.sub.url ../subrepo &&\n-\t\tcp .git/config pristine-.git-config\n+\t\tcp .git/config pristine-.git-config &&\n+\t\tcp .gitmodules pristine-.gitmodules\n \t)\n '\n \n-test_expect_success 'relative path works with URL' '\n+test_expect_success '../subrepo works with URL - ssh://hostname/repo' '\n \t(\n \t\tcd reltest &&\n \t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n \t\tgit config remote.origin.url ssh://hostname/repo &&\n \t\tgit submodule init &&\n \t\ttest \"$(git config submodule.sub.url)\" = ssh://hostname/subrepo\n \t)\n '\n \n-test_expect_success 'relative path works with user@host:path' '\n+test_expect_success '../subrepo works with port-qualified URL - ssh://hostname:22/repo' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url ssh://hostname:22/repo &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = ssh://hostname:22/subrepo\n+\t)\n+'\n+\n+test_expect_success '../subrepo path works with local path - /foo/repo' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url /foo/repo &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = /foo/subrepo\n+\t)\n+'\n+\n+test_expect_success '../subrepo works with file URL - file:///tmp/repo' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url file:///tmp/repo &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = file:///tmp/subrepo\n+\t)\n+'\n+\n+test_expect_success '../subrepo works with helper URL- helper:://hostname/repo' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url helper:://hostname/repo &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = helper:://hostname/subrepo\n+\t)\n+'\n+\n+test_expect_success '../subrepo works with scp-style URL - user@host:repo' '\n \t(\n \t\tcd reltest &&\n \t\tcp pristine-.git-config .git/config &&\n@@ -507,6 +553,64 @@ test_expect_success 'relative path works with user@host:path' '\n \t)\n '\n \n+test_expect_success '../subrepo works with scp-style URL - user@host:path/to/repo' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url user@host:path/to/repo &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = user@host:path/to/subrepo\n+\t)\n+'\n+\n+test_expect_success '../subrepo works with relative local path - foo/bar' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url foo/bar &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = foo/subrepo\n+\t)\n+'\n+\n+test_expect_success '../subrepo works with relative local path - ../foo' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url ../foo &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = ../subrepo\n+\t)\n+'\n+\n+test_expect_success '../subrepo works with relative local path - ../foo/bar' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url ../foo/bar &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = ../foo/subrepo\n+\t)\n+'\n+\n+test_expect_success '../bar/a/b/c works with relative local path - ../foo/bar.git' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tmkdir -p a/b/c &&\n+\t\t(cd a/b/c; git init) &&\n+\t\tgit config remote.origin.url ../foo/bar.git &&\n+\t\tgit submodule add ../bar/a/b/c ./a/b/c &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.a/b/c.url)\" = ../foo/bar/a/b/c\n+\t)\n+'\n+\n test_expect_success 'moving the superproject does not break submodules' '\n \t(\n \t\tcd addtest &&\n-- \n1.7.10.2.652.gdffd412\n"},{"id":"192745","messageId":"1338716810-9881-3-git-send-email-jon.seymour@gmail.com","threadId":"30690","inReplyTo":"1338716810-9881-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 2/4] submodule: document failure to handle relative superproject origin URLs","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2012-06-03T09:46:48Z","receivedAt":"2012-06-03T09:46:48Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This test case documents several cases where handling of relative\nsuperproject origin URLs doesn't produce an expected result.\n\nsubmodule.{sub}.url in the superproject is incorrect in these cases:\n  foo\n  ./foo\n  ./foo/bar\n\nThe remote.origin.url of the submodule is incorrect in the above cases\nand also when the superproject origin URL is like:\n  foo/bar\n  ../foo\n  ../foo/bar\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n t/t7400-submodule-basic.sh | 34 ++++++++++++++++++\n t/t7403-submodule-sync.sh  | 90 +++++++++++++++++++++++++++++++++++++++++++++-\n 2 files changed, 123 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 9428c7a..09e2b9b 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -564,6 +564,18 @@ test_expect_success '../subrepo works with scp-style URL - user@host:path/to/rep\n \t)\n '\n \n+test_expect_failure '../subrepo works with relative local path - foo' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url foo &&\n+\t\t# actual: fails with an error\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = subrepo\n+\t)\n+'\n+\n test_expect_success '../subrepo works with relative local path - foo/bar' '\n \t(\n \t\tcd reltest &&\n@@ -575,6 +587,28 @@ test_expect_success '../subrepo works with relative local path - foo/bar' '\n \t)\n '\n \n+test_expect_failure '../subrepo works with relative local path - ./foo' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url ./foo &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = subrepo\n+\t)\n+'\n+\n+test_expect_failure '../subrepo works with relative local path - ./foo/bar' '\n+\t(\n+\t\tcd reltest &&\n+\t\tcp pristine-.git-config .git/config &&\n+\t\tcp pristine-.gitmodules .gitmodules &&\n+\t\tgit config remote.origin.url ./foo/bar &&\n+\t\tgit submodule init &&\n+\t\ttest \"$(git config submodule.sub.url)\" = foo/subrepo\n+\t)\n+'\n+\n test_expect_success '../subrepo works with relative local path - ../foo' '\n \t(\n \t\tcd reltest &&\ndiff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh\nindex 3620215..56b933d 100755\n--- a/t/t7403-submodule-sync.sh\n+++ b/t/t7403-submodule-sync.sh\n@@ -26,7 +26,9 @@ test_expect_success setup '\n \t(cd super-clone && git submodule update --init) &&\n \tgit clone super empty-clone &&\n \t(cd empty-clone && git submodule init) &&\n-\tgit clone super top-only-clone\n+\tgit clone super top-only-clone &&\n+\tgit clone super relative-clone &&\n+\t(cd relative-clone && git submodule update --init)\n '\n \n test_expect_success 'change submodule' '\n@@ -86,4 +88,90 @@ test_expect_success '\"git submodule sync\" should not vivify uninteresting submod\n \t)\n '\n \n+test_expect_failure '\"git submodule sync\" handles origin URL of the form foo' '\n+\t(cd relative-clone &&\n+\t git remote set-url origin foo &&\n+\t git submodule sync &&\n+\t(cd submodule &&\n+\t #actual fails with: \"cannot strip off url foo\n+\t test \"$(git config remote.origin.url)\" = \"../submodule\"\n+\t)\n+\t)\n+'\n+\n+test_expect_failure '\"git submodule sync\" handles origin URL of the form foo/bar' '\n+\t(cd relative-clone &&\n+\t git remote set-url origin foo/bar &&\n+\t git submodule sync &&\n+\t(cd submodule &&\n+\t #actual foo/submodule\n+\t test \"$(git config remote.origin.url)\" = \"../foo/submodule\"\n+\t)\n+\t)\n+'\n+\n+test_expect_failure '\"git submodule sync\" handles origin URL of the form ./foo' '\n+\t(cd relative-clone &&\n+\t git remote set-url origin ./foo &&\n+\t git submodule sync &&\n+\t(cd submodule &&\n+\t #actual ./submodule\n+\t test \"$(git config remote.origin.url)\" = \"../submodule\"\n+\t)\n+\t)\n+'\n+\n+test_expect_failure '\"git submodule sync\" handles origin URL of the form ./foo/bar' '\n+\t(cd relative-clone &&\n+\t git remote set-url origin ./foo/bar &&\n+\t git submodule sync &&\n+\t(cd submodule &&\n+\t #actual ./foo/submodule\n+\t test \"$(git config remote.origin.url)\" = \"../foo/submodule\"\n+\t)\n+\t)\n+'\n+\n+test_expect_failure '\"git submodule sync\" handles origin URL of the form ../foo' '\n+\t(cd relative-clone &&\n+\t git remote set-url origin ../foo &&\n+\t git submodule sync &&\n+\t(cd submodule &&\n+\t #actual ../submodule\n+\t test \"$(git config remote.origin.url)\" = \"../../submodule\"\n+\t)\n+\t)\n+'\n+\n+test_expect_failure '\"git submodule sync\" handles origin URL of the form ../foo/bar' '\n+\t(cd relative-clone &&\n+\t git remote set-url origin ../foo/bar &&\n+\t git submodule sync &&\n+\t(cd submodule &&\n+\t #actual ../foo/submodule\n+\t test \"$(git config remote.origin.url)\" = \"../../foo/submodule\"\n+\t)\n+\t)\n+'\n+\n+test_expect_failure '\"git submodule sync\" handles origin URL of the form ../foo/bar with deeply nested submodule' '\n+\t(cd relative-clone &&\n+\t git remote set-url origin ../foo/bar &&\n+\t mkdir -p a/b/c &&\n+\t ( cd a/b/c &&\n+\t   git init &&\n+\t   :> .gitignore &&\n+\t   git add .gitignore &&\n+\t   test_tick &&\n+\t   git commit -m \"initial commit\" ) &&\n+\t git submodule add ../bar/a/b/c ./a/b/c &&\n+\t git submodule sync &&\n+\t(cd a/b/c &&\n+\t #actual ../foo/bar/a/b/c\n+\t test \"$(git config remote.origin.url)\" = \"../../../../foo/bar/a/b/c\"\n+\t)\n+\t)\n+'\n+\n+\n test_done\n-- \n1.7.10.2.652.gdffd412\n"},{"id":"192746","messageId":"1338716810-9881-4-git-send-email-jon.seymour@gmail.com","threadId":"30690","inReplyTo":"1338716810-9881-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 3/4] submodule: fix sync handling of some relative superproject origin URLs","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2012-06-03T09:46:49Z","receivedAt":"2012-06-03T09:46:49Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"When the origin URL of the superproject is itself relative, git submodule sync\nconfigures the remote.origin.url configuration property of the submodule\nwith a path that is relative to the work tree of the superproject\nrather than the work tree of the submodule.\n\nTo fix this an 'up_path' that navigates from the work tree of the submodule\nto the work tree of the superproject needs to be prepended to the URL\notherwise calculated.\n\nCorrect handling of superproject origin URLs like foo, ./foo and ./foo/bar is\nleft to a subsequent patch since an additional change is required to handle\nthese cases.\n\nThe documentation of resolve_relative_url() is expanded to give a more thorough\ndescription of the function's objective is intended to be.\n\nThis change also renames the url variable used by cmd_sync() to module_url\nand introduces two new variables super_config_url and sub_origin_url to help\nexplain the purpose of the different urls derived from the module_url.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-submodule.sh          | 53 ++++++++++++++++++++++++++++++++++++++++-------\n t/t7403-submodule-sync.sh |  8 +++----\n 2 files changed, 50 insertions(+), 11 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 64a70d6..314df20 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -30,7 +30,22 @@ nofetch=\n update=\n prefix=\n \n-# Resolve relative url by appending to parent's url\n+# The function takes at most 2 arguments. The first argument is the\n+# relative URL that navigates from the superproject origin repo to the\n+# submodule origin repo. The second up_path argument, if specified, is\n+# the relative path that navigates from the submodule working tree to\n+# the superproject working tree.\n+#\n+# The output of the function is the origin URL of the submodule.\n+#\n+# The output will either be an absolute URL or filesystem path (if the\n+# superproject origin URL is an absolute URL or filesystem path,\n+# respectively) or a relative file system path (if the superproject\n+# origin URL is a relative file system path).\n+#\n+# When the output is a relative file system path, the path is either\n+# relative to the submodule working tree, if up_path is specified, or to\n+# the superproject working tree otherwise.\n resolve_relative_url ()\n {\n \tremote=$(get_default_remote)\n@@ -39,6 +54,17 @@ resolve_relative_url ()\n \turl=\"$1\"\n \tremoteurl=${remoteurl%/}\n \tsep=/\n+\tup_path=\"$2\"\n+\n+\tcase \"$remoteurl\" in\n+\t\t*:*|/*)\n+\t\t\tis_relative=\n+\t\t\t;;\n+\t\t*)\n+\t\t\tis_relative=t\n+\t\t\t;;\n+\tesac\n+\n \twhile test -n \"$url\"\n \tdo\n \t\tcase \"$url\" in\n@@ -64,7 +90,7 @@ resolve_relative_url ()\n \t\t\tbreak;;\n \t\tesac\n \tdone\n-\techo \"$remoteurl$sep${url%/}\"\n+\techo \"${is_relative:+${up_path}}$remoteurl$sep${url%/}\"\n }\n \n #\n@@ -959,19 +985,32 @@ cmd_sync()\n \twhile read mode sha1 stage sm_path\n \tdo\n \t\tname=$(module_name \"$sm_path\")\n-\t\turl=$(git config -f .gitmodules --get submodule.\"$name\".url)\n+\t\t# path from superproject origin repo to submodule origin repo\n+\t\tmodule_url=$(git config -f .gitmodules --get submodule.\"$name\".url)\n \n \t\t# Possibly a url relative to parent\n-\t\tcase \"$url\" in\n+\t\tcase \"$module_url\" in\n \t\t./*|../*)\n-\t\t\turl=$(resolve_relative_url \"$url\") || exit\n+\t\t\t# rewrite foo/bar as ../.. to find path from\n+\t\t\t# submodule work tree to superproject work tree\n+\t\t\tup_path=\"$(echo \"$sm_path\" | sed \"s/[^/]*/../g\")\" &&\n+\t\t\t# guarantee a trailing /\n+\t\t\tup_path=${up_path%/}/ &&\n+\t\t\t# path from submodule work tree to submodule origin repo\n+\t\t\tsub_origin_url=$(resolve_relative_url \"$module_url\" \"$up_path\") &&\n+\t\t\t# path from superproject work tree to submodule origin repo\n+\t\t\tsuper_config_url=$(resolve_relative_url \"$module_url\") || exit\n+\t\t\t;;\n+\t\t*)\n+\t\t\tsub_origin_url=\"$module_url\"\n+\t\t\tsuper_config_url=\"$module_url\"\n \t\t\t;;\n \t\tesac\n \n \t\tif git config \"submodule.$name.url\" >/dev/null 2>/dev/null\n \t\tthen\n \t\t\tsay \"$(eval_gettext \"Synchronizing submodule url for '\\$name'\")\"\n-\t\t\tgit config submodule.\"$name\".url \"$url\"\n+\t\t\tgit config submodule.\"$name\".url \"$super_config_url\"\n \n \t\t\tif test -e \"$sm_path\"/.git\n \t\t\tthen\n@@ -979,7 +1018,7 @@ cmd_sync()\n \t\t\t\tclear_local_git_env\n \t\t\t\tcd \"$sm_path\"\n \t\t\t\tremote=$(get_default_remote)\n-\t\t\t\tgit config remote.\"$remote\".url \"$url\"\n+\t\t\t\tgit config remote.\"$remote\".url \"$sub_origin_url\"\n \t\t\t)\n \t\t\tfi\n \t\tfi\ndiff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh\nindex 56b933d..98bc74a 100755\n--- a/t/t7403-submodule-sync.sh\n+++ b/t/t7403-submodule-sync.sh\n@@ -99,7 +99,7 @@ test_expect_failure '\"git submodule sync\" handles origin URL of the form foo' '\n \t)\n '\n \n-test_expect_failure '\"git submodule sync\" handles origin URL of the form foo/bar' '\n+test_expect_success '\"git submodule sync\" handles origin URL of the form foo/bar' '\n \t(cd relative-clone &&\n \t git remote set-url origin foo/bar &&\n \t git submodule sync &&\n@@ -132,7 +132,7 @@ test_expect_failure '\"git submodule sync\" handles origin URL of the form ./foo/b\n \t)\n '\n \n-test_expect_failure '\"git submodule sync\" handles origin URL of the form ../foo' '\n+test_expect_success '\"git submodule sync\" handles origin URL of the form ../foo' '\n \t(cd relative-clone &&\n \t git remote set-url origin ../foo &&\n \t git submodule sync &&\n@@ -143,7 +143,7 @@ test_expect_failure '\"git submodule sync\" handles origin URL of the form ../foo'\n \t)\n '\n \n-test_expect_failure '\"git submodule sync\" handles origin URL of the form ../foo/bar' '\n+test_expect_success '\"git submodule sync\" handles origin URL of the form ../foo/bar' '\n \t(cd relative-clone &&\n \t git remote set-url origin ../foo/bar &&\n \t git submodule sync &&\n@@ -154,7 +154,7 @@ test_expect_failure '\"git submodule sync\" handles origin URL of the form ../foo/\n \t)\n '\n \n-test_expect_failure '\"git submodule sync\" handles origin URL of the form ../foo/bar with deeply nested submodule' '\n+test_expect_success '\"git submodule sync\" handles origin URL of the form ../foo/bar with deeply nested submodule' '\n \t(cd relative-clone &&\n \t git remote set-url origin ../foo/bar &&\n \t mkdir -p a/b/c &&\n-- \n1.7.10.2.652.gdffd412\n"},{"id":"192747","messageId":"1338716810-9881-5-git-send-email-jon.seymour@gmail.com","threadId":"30690","inReplyTo":"1338716810-9881-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v8 4/4] submodule: fix handling of superproject origin URLs like foo, ./foo and ./foo/bar","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2012-06-03T09:46:50Z","receivedAt":"2012-06-03T09:46:50Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Currently git submodule init and git submodule sync fail with an error\nif the superproject origin URL is of the form foo but succeeds if the\nsuperproject origin URL is of the form ./foo or ./foo/bar or foo/bar.\n\nThis change makes handling of the foo case behave like the handling\nof the ./foo case and also ensures that superfluous leading ./'s are\nremoved from the resulting derived URLs.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-submodule.sh           | 14 ++++++++++++--\n t/t7400-submodule-basic.sh |  6 +++---\n t/t7403-submodule-sync.sh  |  6 +++---\n 3 files changed, 18 insertions(+), 8 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 314df20..5142379 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -60,8 +60,12 @@ resolve_relative_url ()\n \t\t*:*|/*)\n \t\t\tis_relative=\n \t\t\t;;\n+\t\t./*|../*)\n+\t\t\tis_relative=t\n+\t\t\t;;\n \t\t*)\n \t\t\tis_relative=t\n+\t\t\tremoteurl=\"./$remoteurl\"\n \t\t\t;;\n \tesac\n \n@@ -79,7 +83,12 @@ resolve_relative_url ()\n \t\t\t\tsep=:\n \t\t\t\t;;\n \t\t\t*)\n-\t\t\t\tdie \"$(eval_gettext \"cannot strip one component off url '\\$remoteurl'\")\"\n+\t\t\t\tif test -z \"$is_relative\" || test \".\" = \"$remoteurl\"\n+\t\t\t\tthen\n+\t\t\t\t\tdie \"$(eval_gettext \"cannot strip one component off url '\\$remoteurl'\")\"\n+\t\t\t\telse\n+\t\t\t\t\tremoteurl=.\n+\t\t\t\tfi\n \t\t\t\t;;\n \t\t\tesac\n \t\t\t;;\n@@ -90,7 +99,8 @@ resolve_relative_url ()\n \t\t\tbreak;;\n \t\tesac\n \tdone\n-\techo \"${is_relative:+${up_path}}$remoteurl$sep${url%/}\"\n+\tremoteurl=\"$remoteurl$sep${url%/}\"\n+\techo \"${is_relative:+${up_path}}${remoteurl#./}\"\n }\n \n #\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 09e2b9b..a899e6d 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -564,7 +564,7 @@ test_expect_success '../subrepo works with scp-style URL - user@host:path/to/rep\n \t)\n '\n \n-test_expect_failure '../subrepo works with relative local path - foo' '\n+test_expect_success '../subrepo works with relative local path - foo' '\n \t(\n \t\tcd reltest &&\n \t\tcp pristine-.git-config .git/config &&\n@@ -587,7 +587,7 @@ test_expect_success '../subrepo works with relative local path - foo/bar' '\n \t)\n '\n \n-test_expect_failure '../subrepo works with relative local path - ./foo' '\n+test_expect_success '../subrepo works with relative local path - ./foo' '\n \t(\n \t\tcd reltest &&\n \t\tcp pristine-.git-config .git/config &&\n@@ -598,7 +598,7 @@ test_expect_failure '../subrepo works with relative local path - ./foo' '\n \t)\n '\n \n-test_expect_failure '../subrepo works with relative local path - ./foo/bar' '\n+test_expect_success '../subrepo works with relative local path - ./foo/bar' '\n \t(\n \t\tcd reltest &&\n \t\tcp pristine-.git-config .git/config &&\ndiff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh\nindex 98bc74a..524d5c1 100755\n--- a/t/t7403-submodule-sync.sh\n+++ b/t/t7403-submodule-sync.sh\n@@ -88,7 +88,7 @@ test_expect_success '\"git submodule sync\" should not vivify uninteresting submod\n \t)\n '\n \n-test_expect_failure '\"git submodule sync\" handles origin URL of the form foo' '\n+test_expect_success '\"git submodule sync\" handles origin URL of the form foo' '\n \t(cd relative-clone &&\n \t git remote set-url origin foo &&\n \t git submodule sync &&\n@@ -110,7 +110,7 @@ test_expect_success '\"git submodule sync\" handles origin URL of the form foo/bar\n \t)\n '\n \n-test_expect_failure '\"git submodule sync\" handles origin URL of the form ./foo' '\n+test_expect_success '\"git submodule sync\" handles origin URL of the form ./foo' '\n \t(cd relative-clone &&\n \t git remote set-url origin ./foo &&\n \t git submodule sync &&\n@@ -121,7 +121,7 @@ test_expect_failure '\"git submodule sync\" handles origin URL of the form ./foo'\n \t)\n '\n \n-test_expect_failure '\"git submodule sync\" handles origin URL of the form ./foo/bar' '\n+test_expect_success '\"git submodule sync\" handles origin URL of the form ./foo/bar' '\n \t(cd relative-clone &&\n \t git remote set-url origin ./foo/bar &&\n \t git submodule sync &&\n-- \n1.7.10.2.652.gdffd412\n"},{"id":"192776","messageId":"7v1ulwxd0o.fsf@alter.siamese.dyndns.org","threadId":"30690","inReplyTo":"1338716810-9881-4-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v8 3/4] submodule: fix sync handling of some relative superproject origin URLs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-03T22:10:31Z","receivedAt":"2012-06-03T22:10:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Seymour <jon.seymour@gmail.com> writes:\n\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index 64a70d6..314df20 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -30,7 +30,22 @@ nofetch=\n>  update=\n>  prefix=\n>  \n> -# Resolve relative url by appending to parent's url\n> +# The function takes at most 2 arguments. The first argument is the\n> +# relative URL that navigates from the superproject origin repo to the\n> +# submodule origin repo. The second up_path argument, if specified, is\n> +# the relative path that navigates from the submodule working tree to\n> +# the superproject working tree.\n> +#\n> +# The output of the function is the origin URL of the submodule.\n> +#\n> +# The output will either be an absolute URL or filesystem path (if the\n> +# superproject origin URL is an absolute URL or filesystem path,\n> +# respectively) or a relative file system path (if the superproject\n> +# origin URL is a relative file system path).\n> +#\n> +# When the output is a relative file system path, the path is either\n> +# relative to the submodule working tree, if up_path is specified, or to\n> +# the superproject working tree otherwise.\n>  resolve_relative_url ()\n\nOK.\n\n> @@ -39,6 +54,17 @@ resolve_relative_url ()\n>  \turl=\"$1\"\n>  \tremoteurl=${remoteurl%/}\n>  \tsep=/\n> +\tup_path=\"$2\"\n> +\n> +\tcase \"$remoteurl\" in\n> +\t\t*:*|/*)\n> +\t\t\tis_relative=\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\tis_relative=t\n> +\t\t\t;;\n> +\tesac\n\nStyle: please align case/esac and the labels on case arms (see how\ntwo existing nested case statements in this function are written).\n\n> @@ -959,19 +985,32 @@ cmd_sync()\n>  \twhile read mode sha1 stage sm_path\n>  \tdo\n>  \t\tname=$(module_name \"$sm_path\")\n> -\t\turl=$(git config -f .gitmodules --get submodule.\"$name\".url)\n> +\t\t# path from superproject origin repo to submodule origin repo\n> +\t\tmodule_url=$(git config -f .gitmodules --get submodule.\"$name\".url)\n>  \n>  \t\t# Possibly a url relative to parent\n> -\t\tcase \"$url\" in\n> +\t\tcase \"$module_url\" in\n>  \t\t./*|../*)\n> -\t\t\turl=$(resolve_relative_url \"$url\") || exit\n> +\t\t\t# rewrite foo/bar as ../.. to find path from\n> +\t\t\t# submodule work tree to superproject work tree\n> +\t\t\tup_path=\"$(echo \"$sm_path\" | sed \"s/[^/]*/../g\")\" &&\n\nDidn't we add some workaround for implementations of sed that do not\nmatch and replace a possibly empty pattern?  Am I seeing the same\nbreakage as c5bc42b (Avoid bug in Solaris xpg4/sed as used in\nsubmodule, 2012-04-09) addressed with this patch?\n"},{"id":"192782","messageId":"CAH3AnrrUNq9q54dxQidAKD5oAmTSs2hJnWR09jWxmZFYgnfKFw@mail.gmail.com","threadId":"30690","inReplyTo":"7v1ulwxd0o.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v8 3/4] submodule: fix sync handling of some relative superproject origin URLs","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2012-06-03T23:52:05Z","receivedAt":"2012-06-03T23:52:05Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Mon, Jun 4, 2012 at 8:10 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jon Seymour <jon.seymour@gmail.com> writes:\n>\n> Style: please align case/esac and the labels on case arms (see how\n> two existing nested case statements in this function are written).\n\nThanks.\n\n> Didn't we add some workaround for implementations of sed that do not\n> match and replace a possibly empty pattern?  Am I seeing the same\n> breakage as c5bc42b (Avoid bug in Solaris xpg4/sed as used in\n> submodule, 2012-04-09) addressed with this patch?\n\nHave modified accordingly. It may not have mattered *much* in this\ncase since I think\nnormalisation during git submodule add would have ensured at least one matching\ncharacter, but then I don't pretend to understand the nature of the\nSolaris issue and\nthat would in any case, not protect against a manual .gitmodules edit.\n\nI'll re-roll in a day or so after Jens (and/or others) have had a\nchance to comment.\n\njon.\n"},{"id":"192955","messageId":"4FCE77AA.6060005@web.de","threadId":"30690","inReplyTo":"1338716810-9881-4-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v8 3/4] submodule: fix sync handling of some relative superproject origin URLs","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-06-05T21:18:34Z","receivedAt":"2012-06-05T21:18:34Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 03.06.2012 11:46, schrieb Jon Seymour:\n> @@ -959,19 +985,32 @@ cmd_sync()\n>  \twhile read mode sha1 stage sm_path\n>  \tdo\n>  \t\tname=$(module_name \"$sm_path\")\n> -\t\turl=$(git config -f .gitmodules --get submodule.\"$name\".url)\n> +\t\t# path from superproject origin repo to submodule origin repo\n\nThis comment is misleading as it only describes part of the truth, in a lot\nof cases it'll just be an absolute URL of the submodule.\n\n> +\t\tmodule_url=$(git config -f .gitmodules --get submodule.\"$name\".url)\n\nAnd I see no real value of renaming \"url\" to \"module_url\" here (but maybe\nthat is just me).\n\nSo I'd vote for dropping that comment and the \"url\" to \"module_url\" change.\nBut apart from that and the issues Junio mentioned in his response this\nseries is looking good to me.\n"},{"id":"192958","messageId":"7v7gvlnzlz.fsf@alter.siamese.dyndns.org","threadId":"30690","inReplyTo":"4FCE77AA.6060005@web.de","subject":"Re: [PATCH v8 3/4] submodule: fix sync handling of some relative superproject origin URLs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-05T22:49:28Z","receivedAt":"2012-06-05T22:49:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jens Lehmann <Jens.Lehmann@web.de> writes:\n\n> Am 03.06.2012 11:46, schrieb Jon Seymour:\n>> @@ -959,19 +985,32 @@ cmd_sync()\n>>  \twhile read mode sha1 stage sm_path\n>>  \tdo\n>>  \t\tname=$(module_name \"$sm_path\")\n>> -\t\turl=$(git config -f .gitmodules --get submodule.\"$name\".url)\n>> +\t\t# path from superproject origin repo to submodule origin repo\n>\n> This comment is misleading as it only describes part of the truth, in a lot\n> of cases it'll just be an absolute URL of the submodule.\n>\n>> +\t\tmodule_url=$(git config -f .gitmodules --get submodule.\"$name\".url)\n>\n> And I see no real value of renaming \"url\" to \"module_url\" here (but maybe\n> that is just me).\n\nI tend to agree; there is no other kind of URL involved, and I do\nnot see a clear motivation behind this renaming.  Renaming url to\nmodule_url would not help much if it is to differenciate URLs to the\nrepositories of submodule and superproject, so that can't be it.\n\nIn any case, I suspect that you would be involved in maintaining\nthis code in the long haul, so even if it were \"just you\", your\nopinion counts.\n\n> So I'd vote for dropping that comment and the \"url\" to \"module_url\" change.\n> But apart from that and the issues Junio mentioned in his response this\n> series is looking good to me.\n\nThanks for looking this over.\n"},{"id":"192972","messageId":"CAH3AnrpFg=mUcrRMUhbFvShnXwpvJa5eE-VsqcJm0MNMz8C6zA@mail.gmail.com","threadId":"30690","inReplyTo":"7v7gvlnzlz.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v8 3/4] submodule: fix sync handling of some relative superproject origin URLs","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2012-06-06T11:09:59Z","receivedAt":"2012-06-06T11:09:59Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Wed, Jun 6, 2012 at 8:49 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jens Lehmann <Jens.Lehmann@web.de> writes:\n>\n>> Am 03.06.2012 11:46, schrieb Jon Seymour:\n>>> @@ -959,19 +985,32 @@ cmd_sync()\n>>>      while read mode sha1 stage sm_path\n>>>      do\n>>>              name=$(module_name \"$sm_path\")\n>>> -            url=$(git config -f .gitmodules --get submodule.\"$name\".url)\n>>> +            # path from superproject origin repo to submodule origin repo\n>>\n>> This comment is misleading as it only describes part of the truth, in a lot\n>> of cases it'll just be an absolute URL of the submodule.\n\nDone. v9 3/4 also updates the header comments for resolve_relative_url to remove\na similar misleading implication.\n\n>>\n>>> +            module_url=$(git config -f .gitmodules --get submodule.\"$name\".url)\n>>\n>> And I see no real value of renaming \"url\" to \"module_url\" here (but maybe\n>> that is just me).\n>\n> I tend to agree; there is no other kind of URL involved, and I do\n> not see a clear motivation behind this renaming.  Renaming url to\n> module_url would not help much if it is to differenciate URLs to the\n> repositories of submodule and superproject, so that can't be it.\n>\n> In any case, I suspect that you would be involved in maintaining\n> this code in the long haul, so even if it were \"just you\", your\n> opinion counts.\n>\n\nThis is reverted in v9.\n\n>> So I'd vote for dropping that comment and the \"url\" to \"module_url\" change.\n>> But apart from that and the issues Junio mentioned in his response this\n>> series is looking good to me.\n>\n> Thanks for looking this over.\n\nYes, thank you all.\n\njon.\n"}]}