diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2014-12-16 08:57:05 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-12-30 17:02:50 +0000 |
| commit | fe794b2ea7fa2b59c2394eb874c4be99c115c693 (patch) | |
| tree | b8e6bb148cf6a911366f86d21c87ace163046244 /tests/network | |
| parent | 4eb97ef3bf18403fbce351ae4cac673655d2886a (diff) | |
| download | libgit2-fe794b2ea7fa2b59c2394eb874c4be99c115c693.tar.gz | |
remote: remove git_push from the public APIcmn/hide-push
Instead we provide git_remote_upload() and git_remote_update_tips() in
order to have a parallel API for fetching and pushing.
Diffstat (limited to 'tests/network')
| -rw-r--r-- | tests/network/remote/local.c | 35 | ||||
| -rw-r--r-- | tests/network/remote/remotes.c | 14 |
2 files changed, 23 insertions, 26 deletions
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c index baeb25df4..55453061b 100644 --- a/tests/network/remote/local.c +++ b/tests/network/remote/local.c @@ -7,6 +7,14 @@ static git_repository *repo; static git_buf file_path_buf = GIT_BUF_INIT; static git_remote *remote; +static char *push_refspec_strings[] = { + "refs/heads/master", +}; +static git_strarray push_array = { + push_refspec_strings, + 1, +}; + void test_network_remote_local__initialize(void) { cl_git_pass(git_repository_init(&repo, "remotelocal/", 0)); @@ -191,9 +199,9 @@ void test_network_remote_local__push_to_bare_remote(void) refspec_strings, 1, }; + /* Should be able to push to a bare remote */ git_remote *localremote; - git_push *push; /* Get some commits */ connect_to_local_repository(cl_fixture("testrepo.git")); @@ -213,12 +221,9 @@ void test_network_remote_local__push_to_bare_remote(void) cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH)); /* Try to push */ - cl_git_pass(git_push_new(&push, localremote)); - cl_git_pass(git_push_add_refspec(push, "refs/heads/master")); - cl_git_pass(git_push_finish(push)); + cl_git_pass(git_remote_upload(remote, &push_array, NULL)); /* Clean up */ - git_push_free(push); git_remote_free(localremote); cl_fixture_cleanup("localbare.git"); } @@ -234,7 +239,6 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void) }; /* Should be able to push to a bare remote */ git_remote *localremote; - git_push *push; const char *url; /* Get some commits */ @@ -258,12 +262,9 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void) cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH)); /* Try to push */ - cl_git_pass(git_push_new(&push, localremote)); - cl_git_pass(git_push_add_refspec(push, "refs/heads/master")); - cl_git_pass(git_push_finish(push)); + cl_git_pass(git_remote_upload(remote, &push_array, NULL)); /* Clean up */ - git_push_free(push); git_remote_free(localremote); cl_fixture_cleanup("localbare.git"); } @@ -280,7 +281,6 @@ void test_network_remote_local__push_to_non_bare_remote(void) }; /* Shouldn't be able to push to a non-bare remote */ git_remote *localremote; - git_push *push; /* Get some commits */ connect_to_local_repository(cl_fixture("testrepo.git")); @@ -300,12 +300,9 @@ void test_network_remote_local__push_to_non_bare_remote(void) cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH)); /* Try to push */ - cl_git_pass(git_push_new(&push, localremote)); - cl_git_pass(git_push_add_refspec(push, "refs/heads/master")); - cl_git_fail_with(git_push_finish(push), GIT_EBAREREPO); + cl_git_fail_with(GIT_EBAREREPO, git_remote_upload(localremote, &push_array, NULL)); /* Clean up */ - git_push_free(push); git_remote_free(localremote); cl_fixture_cleanup("localbare.git"); } @@ -433,7 +430,6 @@ void test_network_remote_local__update_tips_for_new_remote(void) { git_repository *src_repo; git_repository *dst_repo; git_remote *new_remote; - git_push *push; git_reference* branch; /* Copy test repo */ @@ -446,16 +442,13 @@ void test_network_remote_local__update_tips_for_new_remote(void) { /* Push to bare repo */ cl_git_pass(git_remote_create(&new_remote, src_repo, "bare", "./localbare.git")); cl_git_pass(git_remote_connect(new_remote, GIT_DIRECTION_PUSH)); - cl_git_pass(git_push_new(&push, new_remote)); - cl_git_pass(git_push_add_refspec(push, "refs/heads/master")); - cl_git_pass(git_push_finish(push)); + cl_git_pass(git_remote_upload(new_remote, &push_array, NULL)); /* Update tips and make sure remote branch has been created */ - cl_git_pass(git_push_update_tips(push, NULL, NULL)); + cl_git_pass(git_remote_update_tips(new_remote, NULL, NULL)); cl_git_pass(git_branch_lookup(&branch, src_repo, "bare/master", GIT_BRANCH_REMOTE)); git_reference_free(branch); - git_push_free(push); git_remote_free(new_remote); git_repository_free(dst_repo); cl_fixture_cleanup("localbare.git"); diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c index 07ad934c7..995f1d541 100644 --- a/tests/network/remote/remotes.c +++ b/tests/network/remote/remotes.c @@ -72,7 +72,14 @@ void test_network_remote_remotes__error_when_not_found(void) void test_network_remote_remotes__error_when_no_push_available(void) { git_remote *r; - git_push *p; + char *specs = { + "refs/heads/master", + }; + git_strarray arr = { + &specs, + 1, + }; + cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git"), NULL)); @@ -83,11 +90,8 @@ void test_network_remote_remotes__error_when_no_push_available(void) /* Make sure that push is really not available */ r->transport->push = NULL; - cl_git_pass(git_push_new(&p, r)); - cl_git_pass(git_push_add_refspec(p, "refs/heads/master")); - cl_git_fail_with(git_push_finish(p), GIT_ERROR); + cl_git_fail_with(-1, git_remote_upload(r, &arr, NULL)); - git_push_free(p); git_remote_free(r); } |
