diff options
| author | Ben Straub <bs@github.com> | 2012-12-21 08:05:59 -0800 |
|---|---|---|
| committer | Ben Straub <bs@github.com> | 2012-12-21 08:05:59 -0800 |
| commit | 79000951ec907c967a1c322da8c351998676f753 (patch) | |
| tree | 35fac0fcd93f4ccf876d48eb34957ae8ee0b2b3c | |
| parent | 87bc689fbf571aa3cbc77e510f14304cc3502ca5 (diff) | |
| download | libgit2-79000951ec907c967a1c322da8c351998676f753.tar.gz | |
In-memory remotes don't have names
| -rw-r--r-- | include/git2/remote.h | 2 | ||||
| -rw-r--r-- | src/remote.c | 9 | ||||
| -rw-r--r-- | tests-clar/network/remotelocal.c | 2 | ||||
| -rw-r--r-- | tests-clar/network/remoterename.c | 33 | ||||
| -rw-r--r-- | tests-clar/network/remotes.c | 8 |
5 files changed, 22 insertions, 32 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h index aa3f93c7b..319976fc1 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -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); diff --git a/src/remote.c b/src/remote.c index f591af890..4d4614eb2 100644 --- a/src/remote.c +++ b/src/remote.c @@ -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; diff --git a/tests-clar/network/remotelocal.c b/tests-clar/network/remotelocal.c index 1839679de..01492ac50 100644 --- a/tests-clar/network/remotelocal.c +++ b/tests-clar/network/remotelocal.c @@ -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)); } diff --git a/tests-clar/network/remoterename.c b/tests-clar/network/remoterename.c index e960cd75e..90c464ecf 100644 --- a/tests-clar/network/remoterename.c +++ b/tests-clar/network/remoterename.c @@ -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); +} diff --git a/tests-clar/network/remotes.c b/tests-clar/network/remotes.c index b776353a2..456fbc3b1 100644 --- a/tests-clar/network/remotes.c +++ b/tests-clar/network/remotes.c @@ -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)); |
