vendor/libgit2/src/clone.c in rugged-0.28.5 vs vendor/libgit2/src/clone.c in rugged-0.99.0

- old
+ new

@@ -5,23 +5,21 @@ * a Linking Exception. For full terms see the included COPYING file. */ #include "clone.h" -#include <assert.h> - #include "git2/clone.h" #include "git2/remote.h" #include "git2/revparse.h" #include "git2/branch.h" #include "git2/config.h" #include "git2/checkout.h" #include "git2/commit.h" #include "git2/tree.h" #include "remote.h" -#include "fileops.h" +#include "futils.h" #include "refs.h" #include "path.h" #include "repository.h" #include "odb.h" @@ -380,15 +378,16 @@ done: git_buf_dispose(&fromurl); return is_local; } -int git_clone( +static int git__clone( git_repository **out, const char *url, const char *local_path, - const git_clone_options *_options) + const git_clone_options *_options, + int use_existing) { int error = 0; git_repository *repo = NULL; git_remote *origin; git_clone_options options = GIT_CLONE_OPTIONS_INIT; @@ -401,11 +400,11 @@ memcpy(&options, _options, sizeof(git_clone_options)); GIT_ERROR_CHECK_VERSION(&options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options"); /* Only clone to a new directory or an empty directory */ - if (git_path_exists(local_path) && !git_path_is_empty_dir(local_path)) { + if (git_path_exists(local_path) && !use_existing && !git_path_is_empty_dir(local_path)) { git_error_set(GIT_ERROR_INVALID, "'%s' exists and is not an empty directory", local_path); return GIT_EEXISTS; } @@ -453,14 +452,37 @@ *out = repo; return error; } -int git_clone_init_options(git_clone_options *opts, unsigned int version) +int git_clone( + git_repository **out, + const char *url, + const char *local_path, + const git_clone_options *_options) { + return git__clone(out, url, local_path, _options, 0); +} + +int git_clone__submodule( + git_repository **out, + const char *url, + const char *local_path, + const git_clone_options *_options) +{ + return git__clone(out, url, local_path, _options, 1); +} + +int git_clone_options_init(git_clone_options *opts, unsigned int version) +{ GIT_INIT_STRUCTURE_FROM_TEMPLATE( opts, version, git_clone_options, GIT_CLONE_OPTIONS_INIT); return 0; +} + +int git_clone_init_options(git_clone_options *opts, unsigned int version) +{ + return git_clone_options_init(opts, version); } static bool can_link(const char *src, const char *dst, int link) { #ifdef GIT_WIN32