void test_network_remotes__save(void) { git_remote_free(_remote); /* Set up the remote and save it to config */ cl_git_pass(git_remote_new(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2", NULL)); cl_git_pass(git_remote_set_fetchspec(_remote, "refs/heads/*:refs/remotes/upstream/*")); cl_git_pass(git_remote_set_pushspec(_remote, "refs/heads/*:refs/heads/*")); cl_git_pass(git_remote_save(_remote)); git_remote_free(_remote); _remote = NULL; /* Load it from config and make sure everything matches */ cl_git_pass(git_remote_load(&_remote, _repo, "upstream")); _refspec = git_remote_fetchspec(_remote); cl_assert(_refspec != NULL); cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/remotes/upstream/*"); _refspec = git_remote_pushspec(_remote); cl_assert(_refspec != NULL); cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*"); cl_assert_equal_s(git_refspec_dst(_refspec), "refs/heads/*"); }
static void connect_to_local_repository(const char *local_repository) { build_local_file_url(&file_path_buf, local_repository); cl_git_pass(git_remote_new(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL)); cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH)); }
void test_network_remotelocal__initialize(void) { cl_fixture("remotelocal"); cl_git_pass(git_repository_init(&repo, "remotelocal/", 0)); cl_assert(repo != NULL); build_local_file_url(&file_path_buf, "testrepo.git"); cl_git_pass(git_remote_new(&remote, repo, git_buf_cstr(&file_path_buf), NULL)); cl_git_pass(git_remote_connect(remote, GIT_DIR_FETCH)); }
void test_network_remoterename__renaming_an_inmemory_remote_persists_it(void) { git_remote *remote; assert_config_entry_existence(_repo, "remote.durable.url", false); cl_git_pass(git_remote_new(&remote, _repo, NULL, "git://github.com/libgit2/durable.git", NULL)); assert_config_entry_existence(_repo, "remote.durable.url", false); cl_git_pass(git_remote_rename(remote, "durable", dont_call_me_cb, NULL)); assert_config_entry_value(_repo, "remote.durable.url", "git://github.com/libgit2/durable.git"); git_remote_free(remote); }
void test_network_remoterename__renaming_an_inmemory_nameless_remote_notifies_the_inability_to_update_the_fetch_refspec(void) { git_remote *remote; char *expected_refspecs[] = { "+refs/heads/*:refs/remotes/volatile/*", NULL }; assert_config_entry_existence(_repo, "remote.volatile.url", false); cl_git_pass(git_remote_new( &remote, _repo, NULL, "git://github.com/libgit2/volatile.git", "+refs/heads/*:refs/remotes/volatile/*")); cl_git_pass(git_remote_rename(remote, "durable", ensure_refspecs, &expected_refspecs)); git_remote_free(remote); }
int use_unnamed(git_repository *repo, const char *url) { git_remote *remote = NULL; int error; // Create an instance of a remote from the URL. The transport to use // is detected from the URL error = git_remote_new(&remote, repo, url, NULL); if (error < GIT_SUCCESS) goto cleanup; // When connecting, the underlying code needs to know wether we // want to push or fetch error = git_remote_connect(remote, GIT_DIR_FETCH); if (error < GIT_SUCCESS) goto cleanup; // With git_remote_ls we can retrieve the advertised heads error = git_remote_ls(remote, &show_ref__cb, NULL); cleanup: git_remote_free(remote); return error; }