diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-07-13 09:08:32 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-07-13 09:08:32 +0200 |
commit | f00f005bad3d27bb5c23ae5d7187622b940c5d0e (patch) | |
tree | 2d9fb5d46a2aff87d055977ad621db2019784973 | |
parent | aa51fa1e03df9a30c8c37b168758dd34dd75f353 (diff) | |
download | libgit2-f00f005bad3d27bb5c23ae5d7187622b940c5d0e.tar.gz |
submodule: normalize slashes in resolve_url
Our path functions expect to work with slashes, so convert a
path with backslashes into one with slashes at the top of
the function.
-rw-r--r-- | src/submodule.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/submodule.c b/src/submodule.c index fb3d4bf1e..e4469efa3 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -781,11 +781,25 @@ const char *git_submodule_url(git_submodule *submodule) int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *url) { int error = 0; + git_buf normalized = GIT_BUF_INIT; assert(out && repo && url); git_buf_sanitize(out); + if (strchr(url, '\\')) { + char *p; + if ((error = git_buf_puts(&normalized, url)) < 0) + return error; + + for (p = normalized.ptr; *p; p++) { + if (*p == '\\') + *p = '/'; + } + + url = normalized.ptr; + } + if (git_path_is_relative(url)) { if (!(error = get_url_base(out, repo))) error = git_path_apply_relative(out, url); @@ -796,6 +810,7 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur error = -1; } + git_buf_free(&normalized); return error; } |