Commit 79000951 by Ben Straub

In-memory remotes don't have names

parent 87bc689f
......@@ -61,7 +61,6 @@ GIT_EXTERN(int) git_remote_create(
*
* @param out pointer to the new remote object
* @param repo the associated repository. May be NULL for a "dangling" remote.
* @param name the optional remote's name. May be NULL.
* @param url the remote repository's URL
* @param fetch the fetch refspec to use for this remote. May be NULL for defaults.
* @return 0, GIT_EINVALIDSPEC or an error code
......@@ -69,7 +68,6 @@ GIT_EXTERN(int) git_remote_create(
GIT_EXTERN(int) git_remote_create_inmemory(
git_remote **out,
git_repository *repo,
const char *name,
const char *url,
const char *fetch);
......
......@@ -162,12 +162,12 @@ on_error:
return -1;
}
int git_remote_create_inmemory(git_remote **out, git_repository *repo, const char *name, const char *url, const char *fetch)
int git_remote_create_inmemory(git_remote **out, git_repository *repo, const char *url, const char *fetch)
{
int error;
git_remote *remote;
if ((error = create_internal(&remote, repo, name, url, fetch)) < 0)
if ((error = create_internal(&remote, repo, NULL, url, fetch)) < 0)
return error;
remote->inmem = true;
......@@ -1326,6 +1326,11 @@ int git_remote_rename(
assert(remote && new_name);
if (remote->inmem) {
giterr_set(GITERR_INVALID, "Can't rename an in-memory remote.");
return GIT_EINVALIDSPEC;
}
if ((error = ensure_remote_name_is_valid(new_name)) < 0)
return error;
......
......@@ -50,7 +50,7 @@ static void connect_to_local_repository(const char *local_repository)
{
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
cl_git_pass(git_remote_create_inmemory(&remote, repo, NULL, git_buf_cstr(&file_path_buf), NULL));
cl_git_pass(git_remote_create_inmemory(&remote, repo, git_buf_cstr(&file_path_buf), NULL));
cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH));
}
......
......@@ -148,29 +148,6 @@ void test_network_remoterename__cannot_overwrite_an_existing_remote(void)
cl_assert_equal_i(GIT_EEXISTS, git_remote_rename(_remote, "test_with_pushurl", dont_call_me_cb, NULL));
}
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_create_inmemory(
&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);
}
void test_network_remoterename__renaming_a_remote_moves_the_underlying_reference(void)
{
git_reference *underlying;
......@@ -185,3 +162,13 @@ void test_network_remoterename__renaming_a_remote_moves_the_underlying_reference
cl_git_pass(git_reference_lookup(&underlying, _repo, "refs/remotes/just/renamed/master"));
git_reference_free(underlying);
}
void test_network_remoterename__cannot_rename_an_inmemory_remote(void)
{
git_remote *remote;
cl_git_pass(git_remote_create_inmemory(&remote, _repo, "file:///blah", NULL));
cl_git_fail(git_remote_rename(remote, "newname", NULL, NULL));
git_remote_free(remote);
}
......@@ -255,7 +255,7 @@ void test_network_remotes__cant_save_inmem_remote(void)
{
git_remote *remote;
cl_git_pass(git_remote_create_inmemory(&remote, _repo, NULL, "git://github.com/libgit2/libgit2", NULL));
cl_git_pass(git_remote_create_inmemory(&remote, _repo, "git://github.com/libgit2/libgit2", NULL));
cl_git_fail(git_remote_save(remote));
git_remote_free(remote);
......@@ -282,12 +282,12 @@ void test_network_remotes__cannot_initialize_a_remote_with_an_invalid_name(void)
cl_assert_equal_i(
GIT_EINVALIDSPEC,
git_remote_create_inmemory(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2", NULL));
git_remote_create(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2"));
cl_assert_equal_p(remote, NULL);
cl_assert_equal_i(
GIT_EINVALIDSPEC,
git_remote_create_inmemory(&remote, _repo, "", "git://github.com/libgit2/libgit2", NULL));
git_remote_create(&remote, _repo, "", "git://github.com/libgit2/libgit2"));
cl_assert_equal_p(remote, NULL);
}
......@@ -331,7 +331,7 @@ void test_network_remotes__check_structure_version(void)
git_remote_free(_remote);
_remote = NULL;
cl_git_pass(git_remote_create_inmemory(&_remote, _repo, NULL, "test-protocol://localhost", NULL));
cl_git_pass(git_remote_create_inmemory(&_remote, _repo, "test-protocol://localhost", NULL));
transport.version = 0;
cl_git_fail(git_remote_set_transport(_remote, &transport));
......
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