diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-03 21:47:53 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-03 21:47:53 +0200 |
commit | 18d7896cb00b9a4abe55cb461e12db4813e6a59e (patch) | |
tree | e701c6bfee7bc851280a0130463ee98c44dc8faf /src/clone.c | |
parent | bccb36ebf9d950f7562153d9e9ef9a3678e72516 (diff) | |
download | libgit2-18d7896cb00b9a4abe55cb461e12db4813e6a59e.tar.gz |
clone: re-use the local transport's path resolutioncmn/path-to-path
Whe already worked out the kinks with the function used in the local
transport. Expose it and make use of it in the local clone method
instead of trying to work it out again.
Diffstat (limited to 'src/clone.c')
-rw-r--r-- | src/clone.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/clone.c b/src/clone.c index 5aaa94ff6..6c4fb6727 100644 --- a/src/clone.c +++ b/src/clone.c @@ -472,11 +472,10 @@ static bool can_link(const char *src, const char *dst, int link) int git_clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link, const git_signature *signature) { - int error, root, flags; + int error, flags; git_repository *src; git_buf src_odb = GIT_BUF_INIT, dst_odb = GIT_BUF_INIT, src_path = GIT_BUF_INIT; git_buf reflog_message = GIT_BUF_INIT; - const char *url; assert(repo && remote); @@ -490,19 +489,8 @@ int git_clone_local_into(git_repository *repo, git_remote *remote, const git_che * repo, if it's not rooted, the path should be relative to * the repository's worktree/gitdir. */ - url = git_remote_url(remote); - if (!git__prefixcmp(url, "file://")) - root = strlen("file://"); - else - root = git_path_root(url); - - if (root >= 0) - git_buf_puts(&src_path, url + root); - else - git_buf_joinpath(&src_path, repository_base(repo), url); - - if (git_buf_oom(&src_path)) - return -1; + if ((error = git_path_from_url_or_path(&src_path, git_remote_url(remote))) < 0) + return error; /* Copy .git/objects/ from the source to the target */ if ((error = git_repository_open(&src, git_buf_cstr(&src_path))) < 0) { |