From 3389e78ec8cd117f981ce3963a901b66db6c8206 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Mon, 10 Oct 2016 10:56:11 -0700 Subject: submodule: ignore trailing slash in relative url This is similar to the previous patch, though no user reported a bug and I could not find a regressive behavior. However it is a good thing to be strict on the output and for that we always omit a trailing slash. Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 2 ++ t/t0060-path-utils.sh | 1 + 2 files changed, 3 insertions(+) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 612e87084..569bc8cf3 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -149,6 +149,8 @@ static char *relative_url(const char *remote_url, } strbuf_reset(&sb); strbuf_addf(&sb, "%s%s%s", remoteurl, colonsep ? ":" : "/", url); + if (ends_with(url, "/")) + strbuf_setlen(&sb, sb.len - 1); free(remoteurl); if (starts_with_dot_slash(sb.buf)) diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 82b98f8cb..25b48e566 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -319,6 +319,7 @@ test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule" test_submodule_relative_url "../" "foo" "../submodule" "../submodule" test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c" +test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c/" "../foo/sub/a/b/c" test_submodule_relative_url "(null)" "../foo/bar/" "../sub/a/b/c" "../foo/sub/a/b/c" test_submodule_relative_url "(null)" "../foo/bar" "../submodule" "../foo/submodule" test_submodule_relative_url "(null)" "../foo/submodule" "../submodule" "../foo/submodule" -- cgit v1.2.1