Stop premature remote freeing when cloning

This commit is contained in:
Ben Straub 2012-12-13 09:14:56 -08:00
parent 34c8c75433
commit 24393ea6d3
4 changed files with 13 additions and 3 deletions

View File

@ -82,6 +82,7 @@ int do_clone(git_repository *repo, int argc, char **argv)
// Do the clone
error = git_clone(&cloned_repo, origin, path, &checkout_opts, &fetch_progress, &pd);
git_remote_free(origin);
printf("\n");
if (error != 0) {
const git_error *err = giterr_last();

View File

@ -289,7 +289,6 @@ static int setup_remotes_and_fetch(
}
git_remote_disconnect(origin);
}
git_remote_free(origin);
}
return retcode;

View File

@ -17,6 +17,12 @@ void test_clone_network__initialize(void)
cl_git_pass(git_remote_new(&g_origin, NULL, "origin", LIVE_REPO_URL, GIT_REMOTE_DEFAULT_FETCH));
}
void test_clone_network__cleanup(void)
{
git_remote_free(g_origin);
g_origin = NULL;
}
static void cleanup_repository(void *path)
{
if (g_repo) {

View File

@ -14,6 +14,12 @@ void test_clone_nonetwork__initialize(void)
cl_git_pass(git_remote_new(&g_origin, NULL, "origin", cl_git_fixture_url("testrepo.git"), GIT_REMOTE_DEFAULT_FETCH));
}
void test_clone_nonetwork__cleanup(void)
{
git_remote_free(g_origin);
g_origin = NULL;
}
static void cleanup_repository(void *path)
{
if (g_repo) {
@ -56,7 +62,6 @@ void test_clone_nonetwork__fail_when_the_target_is_a_file(void)
cl_git_mkfile("./foo", "Bar!");
cl_git_fail(git_clone(&g_repo, g_origin, "./foo", NULL, NULL, NULL));
git_remote_free(g_origin);
}
void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(void)
@ -66,5 +71,4 @@ void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(vo
p_mkdir("./foo", GIT_DIR_MODE);
cl_git_mkfile("./foo/bar", "Baz!");
cl_git_fail(git_clone(&g_repo, g_origin, "./foo", NULL, NULL, NULL));
git_remote_free(g_origin);
}