Commit fdc7e5e3 by Carlos Martín Nieto

clone: bring back NULL as defaults

This wasremoved as part of the large culling a few commits ago.
parent c833893c
......@@ -390,16 +390,20 @@ int git_clone(
git_repository **out,
const char *url,
const char *local_path,
const git_clone_options *options)
const git_clone_options *_options)
{
int retcode = GIT_ERROR;
git_repository *repo = NULL;
git_remote *origin;
git_clone_options options = GIT_CLONE_OPTIONS_INIT;
int remove_directory_on_failure = 0;
assert(out && url && local_path);
GITERR_CHECK_VERSION(options, GIT_CLONE_OPTIONS_VERSION, "git_clone_options");
if (_options)
memcpy(&options, _options, sizeof(git_clone_options));
GITERR_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)) {
......@@ -411,13 +415,13 @@ int git_clone(
/* Only remove the directory on failure if we create it */
remove_directory_on_failure = !git_path_exists(local_path);
if ((retcode = git_repository_init(&repo, local_path, options->bare)) < 0)
if ((retcode = git_repository_init(&repo, local_path, options.bare)) < 0)
return retcode;
if ((retcode = create_and_configure_origin(&origin, repo, url, options)) < 0)
if ((retcode = create_and_configure_origin(&origin, repo, url, &options)) < 0)
goto cleanup;
retcode = git_clone_into(repo, origin, &options->checkout_opts, options->checkout_branch);
retcode = git_clone_into(repo, origin, &options.checkout_opts, options.checkout_branch);
git_remote_free(origin);
if (retcode < 0)
......
......@@ -130,6 +130,12 @@ void test_clone_nonetwork__custom_origin_name(void)
cl_git_pass(git_remote_load(&g_remote, g_repo, "my_origin"));
}
void test_clone_nonetwork__defaults(void)
{
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", NULL));
cl_assert(g_repo);
cl_git_pass(git_remote_load(&g_remote, g_repo, "origin"));
}
void test_clone_nonetwork__cope_with_already_existing_directory(void)
{
......
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