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 <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Oct 10, 2016 at 10:56 UTC
3389e78ec8cd117f981ce3963a901b66db6c8206
2 files changed
+3
builtin/submodule--helper.c
+2
@@ -149,6 +149,8 @@ static char *relative_url(const char *remote_url,
149
}
150
strbuf_reset(&sb);
151
strbuf_addf(&sb, "%s%s%s", remoteurl, colonsep ? ":" : "/", url);
152
+ if (ends_with(url, "/"))
153
+ strbuf_setlen(&sb, sb.len - 1);
154
free(remoteurl);
155
156
if (starts_with_dot_slash(sb.buf))
t/t0060-path-utils.sh
+1
@@ -319,6 +319,7 @@ test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
319
test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
320
321
test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c"
322
+test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c/" "../foo/sub/a/b/c"
323
test_submodule_relative_url "(null)" "../foo/bar/" "../sub/a/b/c" "../foo/sub/a/b/c"
324
test_submodule_relative_url "(null)" "../foo/bar" "../submodule" "../foo/submodule"
325
test_submodule_relative_url "(null)" "../foo/submodule" "../submodule" "../foo/submodule"