Commit 47a40d1d by Carlos Martín Nieto

remote: return EINVALIDSPEC when given an empty URL

This is what we used to return in the settter and there's tests in
bindings which ask for this. There's no particular reason to stop doing
so.
parent aeb2b991
...@@ -167,14 +167,18 @@ static int get_check_cert(int *out, git_repository *repo) ...@@ -167,14 +167,18 @@ static int get_check_cert(int *out, git_repository *repo)
static int canonicalize_url(git_buf *out, const char *in) static int canonicalize_url(git_buf *out, const char *in)
{ {
#ifdef GIT_WIN32 if (in == NULL || strlen(in) == 0) {
const char *c; giterr_set(GITERR_INVALID, "cannot set empty URL");
return GIT_EINVALIDSPEC;
}
#ifdef GIT_WIN32
/* Given a UNC path like \\server\path, we need to convert this /* Given a UNC path like \\server\path, we need to convert this
* to //server/path for compatibility with core git. * to //server/path for compatibility with core git.
*/ */
if (in[0] == '\\' && in[1] == '\\' && if (in[0] == '\\' && in[1] == '\\' &&
(git__isalpha(in[2]) || git__isdigit(in[2]))) { (git__isalpha(in[2]) || git__isdigit(in[2]))) {
const char *c;
for (c = in; *c; c++) for (c = in; *c; c++)
git_buf_putc(out, *c == '\\' ? '/' : *c); git_buf_putc(out, *c == '\\' ? '/' : *c);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment