tests: update push tests These tests were forgotten when modifying git_remote_ls().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
diff --git a/tests-clar/online/push.c b/tests-clar/online/push.c
index 9ed9717..b5ec77a 100644
--- a/tests-clar/online/push.c
+++ b/tests-clar/online/push.c
@@ -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);
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)
@@ -265,7 +263,8 @@ failed:
void test_online_push__initialize(void)
{
git_vector delete_specs = GIT_VECTOR_INIT;
- size_t i;
+ const git_remote_head **heads;
+ size_t i, heads_len;
char *curr_del_spec;
_repo = cl_git_sandbox_init("push_src");
@@ -322,7 +321,8 @@ void test_online_push__initialize(void)
* 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
*/
- 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) {
git_push *push;
diff --git a/tests-clar/online/push_util.c b/tests-clar/online/push_util.c
index e3f3269..038c144 100644
--- a/tests-clar/online/push_util.c
+++ b/tests-clar/online/push_util.c
@@ -44,20 +44,23 @@ int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid *
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;
+ size_t i;
- /* Ignore malformed ref names (which also saves us from tag^{} */
- if (!git_reference_is_valid_name(head->name))
- return 0;
-
- /* Create a refspec that deletes a branch in the remote */
- if (strcmp(head->name, "refs/heads/master")) {
- cl_git_pass(git_buf_putc(&del_spec, ':'));
- cl_git_pass(git_buf_puts(&del_spec, head->name));
- cl_git_pass(git_vector_insert(delete_specs, git_buf_detach(&del_spec)));
+ for (i = 0; i < heads_len; i++) {
+ const git_remote_head *head = heads[i];
+ /* Ignore malformed ref names (which also saves us from tag^{} */
+ if (!git_reference_is_valid_name(head->name))
+ return 0;
+
+ /* Create a refspec that deletes a branch in the remote */
+ if (strcmp(head->name, "refs/heads/master")) {
+ 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;
diff --git a/tests-clar/online/push_util.h b/tests-clar/online/push_util.h
index e6ddb71..a7207c4 100644
--- a/tests-clar/online/push_util.h
+++ b/tests-clar/online/push_util.h
@@ -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);
/**
- * 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 payload a git_push instance
+ * @param out the vector in which to store the refspecs
+ * @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