Currently git calculates the submodule origin URL incorrectly in the case that the superproject origin URL is denormalized. So, we normalize the path part of the superproject URL before iterating over the leading ../ parts of the submodule URL. A remaining problem related to the handling of consecutive repeated ./'s in the superproject origin URL is deferred to a subsequent commit. This change also fixes a subtle error in the setup of t7403 which was masked by the denormalization issue. Previous behaviour was relying on submodule add to clone trash/submodule into super/submodule, however from the perspective of super's origin (i.e. trash), the origin submodule is actually located at ./submodule not ../submodule. However, because the origin URL of super was denormalized (it had a trailing /.) the incorrect handling of denormalized super URLs actually produced the correct result - a case of two errors cancelling out each other's effects. Signed-off-by: Jon Seymour <jon.seymour@xxxxxxxxx> --- git-submodule.sh | 1 + t/t7400-submodule-basic.sh | 10 +++++----- t/t7403-submodule-sync.sh | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 9ca2ffe..1f0983c 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -76,6 +76,7 @@ resolve_relative_url () ;; esac invariant="${remoteurl%$variant}" + variant="$(normalize_path "$variant")" while test -n "$url" do diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index a94c5e9..b01f479 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -521,7 +521,7 @@ test_expect_failure 'relative path works with URL - ssh://hostname/path/detour/. ) ' -test_expect_failure 'relative path works with URL - ssh://hostname/path/repo/.' ' +test_expect_success 'relative path works with URL - ssh://hostname/path/repo/.' ' ( cd reltest && cp pristine-.git-config .git/config && @@ -663,7 +663,7 @@ test_expect_success '../subrepo works with scp-style URL - user@host:path/to/rep ) ' -test_expect_failure 'relative path works with user@host:path/to/repo/.' ' +test_expect_success 'relative path works with user@host:path/to/repo/.' ' ( cd reltest && cp pristine-.git-config .git/config && @@ -674,7 +674,7 @@ test_expect_failure 'relative path works with user@host:path/to/repo/.' ' ) ' -test_expect_failure 'relative path works with user@host:path/to/./repo' ' +test_expect_success 'relative path works with user@host:path/to/./repo' ' ( cd reltest && cp pristine-.git-config .git/config && @@ -696,7 +696,7 @@ test_expect_failure 'relative path works with user@host:path/to/././repo' ' ) ' -test_expect_failure 'relative path works with user@host:path/to/detour/../repo' ' +test_expect_success 'relative path works with user@host:path/to/detour/../repo' ' ( cd reltest && cp pristine-.git-config .git/config && @@ -773,7 +773,7 @@ test_expect_success '../subrepo works with relative local path - ../foo/bar' ' ) ' -test_expect_failure 'relative path works with ../foo/./bar' ' +test_expect_success 'relative path works with ../foo/./bar' ' ( cd reltest && cp pristine-.git-config .git/config && diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh index b7466ba..0152969 100755 --- a/t/t7403-submodule-sync.sh +++ b/t/t7403-submodule-sync.sh @@ -18,6 +18,7 @@ test_expect_success setup ' git clone . super && git clone super submodule && (cd super && + git clone ../submodule submodule && git submodule add ../submodule submodule && test_tick && git commit -m "submodule" -- 1.7.10.2.656.gb5a46db -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html