Commit ae297212 by Carlos Martín Nieto

tests: update push tests

These tests were forgotten when modifying git_remote_ls().
parent 877cde76
...@@ -160,8 +160,6 @@ static void verify_refs(git_remote *remote, expected_ref expected_refs[], size_t ...@@ -160,8 +160,6 @@ static void verify_refs(git_remote *remote, expected_ref expected_refs[], size_t
git_remote_ls(&actual_refs, &actual_refs_len, remote); git_remote_ls(&actual_refs, &actual_refs_len, remote);
verify_remote_refs(actual_refs, actual_refs_len, expected_refs, expected_refs_len); verify_remote_refs(actual_refs, actual_refs_len, expected_refs, expected_refs_len);
git_vector_free(&actual_refs);
} }
static int tracking_branch_list_cb(const char *branch_name, git_branch_t branch_type, void *payload) static int tracking_branch_list_cb(const char *branch_name, git_branch_t branch_type, void *payload)
...@@ -265,7 +263,8 @@ failed: ...@@ -265,7 +263,8 @@ failed:
void test_online_push__initialize(void) void test_online_push__initialize(void)
{ {
git_vector delete_specs = GIT_VECTOR_INIT; git_vector delete_specs = GIT_VECTOR_INIT;
size_t i; const git_remote_head **heads;
size_t i, heads_len;
char *curr_del_spec; char *curr_del_spec;
_repo = cl_git_sandbox_init("push_src"); _repo = cl_git_sandbox_init("push_src");
...@@ -322,7 +321,8 @@ void test_online_push__initialize(void) ...@@ -322,7 +321,8 @@ void test_online_push__initialize(void)
* order to delete the remote branch pointed to by HEAD (usually master). * order to delete the remote branch pointed to by HEAD (usually master).
* See: https://raw.github.com/git/git/master/Documentation/RelNotes/1.7.0.txt * See: https://raw.github.com/git/git/master/Documentation/RelNotes/1.7.0.txt
*/ */
cl_git_pass(git_remote_ls(_remote, delete_ref_cb, &delete_specs)); cl_git_pass(git_remote_ls(&heads, &heads_len, _remote));
cl_git_pass(create_deletion_refspecs(&delete_specs, heads, heads_len));
if (delete_specs.length) { if (delete_specs.length) {
git_push *push; git_push *push;
......
...@@ -44,20 +44,23 @@ int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid * ...@@ -44,20 +44,23 @@ int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid *
return 0; return 0;
} }
int delete_ref_cb(git_remote_head *head, void *payload) int create_deletion_refspecs(git_vector *out, const git_remote_head **heads, size_t heads_len)
{ {
git_vector *delete_specs = (git_vector *)payload;
git_buf del_spec = GIT_BUF_INIT; git_buf del_spec = GIT_BUF_INIT;
size_t i;
/* Ignore malformed ref names (which also saves us from tag^{} */ for (i = 0; i < heads_len; i++) {
if (!git_reference_is_valid_name(head->name)) const git_remote_head *head = heads[i];
return 0; /* Ignore malformed ref names (which also saves us from tag^{} */
if (!git_reference_is_valid_name(head->name))
/* Create a refspec that deletes a branch in the remote */ return 0;
if (strcmp(head->name, "refs/heads/master")) {
cl_git_pass(git_buf_putc(&del_spec, ':')); /* Create a refspec that deletes a branch in the remote */
cl_git_pass(git_buf_puts(&del_spec, head->name)); if (strcmp(head->name, "refs/heads/master")) {
cl_git_pass(git_vector_insert(delete_specs, git_buf_detach(&del_spec))); cl_git_pass(git_buf_putc(&del_spec, ':'));
cl_git_pass(git_buf_puts(&del_spec, head->name));
cl_git_pass(git_vector_insert(out, git_buf_detach(&del_spec)));
}
} }
return 0; return 0;
......
...@@ -41,12 +41,13 @@ void record_callbacks_data_clear(record_callbacks_data *data); ...@@ -41,12 +41,13 @@ void record_callbacks_data_clear(record_callbacks_data *data);
int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid *b, void *data); int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid *b, void *data);
/** /**
* Callback for git_remote_list that adds refspecs to delete each ref * Create a set of refspecs that deletes each of the inputs
* *
* @param head a ref on the remote * @param out the vector in which to store the refspecs
* @param payload a git_push instance * @param heads the remote heads
* @param heads_len the size of the array
*/ */
int delete_ref_cb(git_remote_head *head, void *payload); int create_deletion_refspecs(git_vector *out, const git_remote_head **heads, size_t heads_len);
/** /**
* Callback for git_remote_list that adds refspecs to vector * Callback for git_remote_list that adds refspecs to vector
......
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