diff options
| author | Vicent Martà <tanoku@gmail.com> | 2012-01-04 22:40:59 +0100 |
|---|---|---|
| committer | Vicent Martà <tanoku@gmail.com> | 2012-01-04 22:43:11 +0100 |
| commit | f2114d0a35b95efef294f7527dfd64fbef61d993 (patch) | |
| tree | ccb5ed2313c8d660cefb3730cd9ca279361ff927 /src/transports/local.c | |
| parent | b0df89d90b4c2aee6e7083031a93667ff9c85ab3 (diff) | |
| parent | e2580375dc76f46dce9963225449fcc872e86b0b (diff) | |
| download | libgit2-f2114d0a35b95efef294f7527dfd64fbef61d993.tar.gz | |
Merge remote-tracking branch 'nulltoken/topix/path_fromurl' into development
Conflicts:
tests-clay/clay.h
tests-clay/clay_main.c
Diffstat (limited to 'src/transports/local.c')
| -rw-r--r-- | src/transports/local.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/transports/local.c b/src/transports/local.c index 2937da06d..a2135e73e 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -13,6 +13,8 @@ #include "refs.h" #include "transport.h" #include "posix.h" +#include "path.h" +#include "buffer.h" typedef struct { git_transport parent; @@ -148,7 +150,6 @@ static int local_ls(git_transport *transport, git_headlist_cb list_cb, void *pay return GIT_SUCCESS; } - /* * Try to open the url as a git directory. The direction doesn't * matter in this case because we're calulating the heads ourselves. @@ -159,24 +160,26 @@ static int local_connect(git_transport *transport, int GIT_UNUSED(direction)) int error; transport_local *t = (transport_local *) transport; const char *path; + git_buf buf = GIT_BUF_INIT; + GIT_UNUSED_ARG(direction); /* The repo layer doesn't want the prefix */ if (!git__prefixcmp(transport->url, "file://")) { - path = transport->url + strlen("file://"); - -#ifdef _MSC_VER - /* skip the leading slash on windows before the drive letter */ - if (*path != '/') - return git__throw(GIT_EINVALIDPATH, "Invalid local uri '%s'.", transport->url); - - path++; -#endif - - } else + error = git_path_fromurl(&buf, transport->url); + if (error < GIT_SUCCESS) { + git_buf_free(&buf); + return git__rethrow(error, "Failed to parse remote path"); + } + path = git_buf_cstr(&buf); + + } else /* We assume transport->url is already a path */ path = transport->url; error = git_repository_open(&repo, path); + + git_buf_free(&buf); + if (error < GIT_SUCCESS) return git__rethrow(error, "Failed to open remote"); |
