Blame tests/online/push_util.h

Packit ae9e2a
#ifndef INCLUDE_cl_push_util_h__
Packit ae9e2a
#define INCLUDE_cl_push_util_h__
Packit ae9e2a
Packit ae9e2a
#include "git2/oid.h"
Packit ae9e2a
Packit ae9e2a
/* Constant for zero oid */
Packit ae9e2a
extern const git_oid OID_ZERO;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Macro for initializing git_remote_callbacks to use test helpers that
Packit ae9e2a
 * record data in a record_callbacks_data instance.
Packit ae9e2a
 * @param data pointer to a record_callbacks_data instance
Packit ae9e2a
 */
Packit ae9e2a
#define RECORD_CALLBACKS_INIT(data) \
Packit ae9e2a
	{ GIT_REMOTE_CALLBACKS_VERSION, NULL, NULL, cred_acquire_cb, NULL, NULL, record_update_tips_cb, NULL, NULL, NULL, NULL, NULL, data }
Packit ae9e2a
Packit ae9e2a
typedef struct {
Packit ae9e2a
	char *name;
Packit ae9e2a
	git_oid old_oid;
Packit ae9e2a
	git_oid new_oid;
Packit ae9e2a
} updated_tip;
Packit ae9e2a
Packit ae9e2a
typedef struct {
Packit ae9e2a
	git_vector updated_tips;
Packit ae9e2a
	git_vector statuses;
Packit ae9e2a
	int pack_progress_calls;
Packit ae9e2a
	int transfer_progress_calls;
Packit ae9e2a
} record_callbacks_data;
Packit ae9e2a
Packit ae9e2a
typedef struct {
Packit ae9e2a
	const char *name;
Packit ae9e2a
	const git_oid *oid;
Packit ae9e2a
} expected_ref;
Packit ae9e2a
Packit ae9e2a
/* the results of a push status.  when used for expected values, msg may be NULL
Packit ae9e2a
 * to indicate that it should not be matched. */
Packit ae9e2a
typedef struct {
Packit ae9e2a
	char *ref;
Packit ae9e2a
	int success;
Packit ae9e2a
	char *msg;
Packit ae9e2a
} push_status;
Packit ae9e2a
Packit ae9e2a
Packit ae9e2a
void updated_tip_free(updated_tip *t);
Packit ae9e2a
Packit ae9e2a
void record_callbacks_data_clear(record_callbacks_data *data);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Callback for git_remote_update_tips that records updates
Packit ae9e2a
 *
Packit ae9e2a
 * @param data (git_vector *) of updated_tip instances
Packit ae9e2a
 */
Packit ae9e2a
int record_update_tips_cb(const char *refname, const git_oid *a, const git_oid *b, void *data);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a set of refspecs that deletes each of the inputs
Packit ae9e2a
 *
Packit ae9e2a
 * @param out the vector in which to store the refspecs
Packit ae9e2a
 * @param heads the remote heads
Packit ae9e2a
 * @param heads_len the size of the array
Packit ae9e2a
 */
Packit ae9e2a
int create_deletion_refspecs(git_vector *out, const git_remote_head **heads, size_t heads_len);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Callback for git_remote_list that adds refspecs to vector
Packit ae9e2a
 *
Packit ae9e2a
 * @param head a ref on the remote
Packit ae9e2a
 * @param payload (git_vector *) of git_remote_head instances
Packit ae9e2a
 */
Packit ae9e2a
int record_ref_cb(git_remote_head *head, void *payload);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Verifies that refs on remote stored by record_ref_cb match the expected
Packit ae9e2a
 * names, oids, and order.
Packit ae9e2a
 *
Packit ae9e2a
 * @param actual_refs actual refs in the remote
Packit ae9e2a
 * @param actual_refs_len length of actual_refs
Packit ae9e2a
 * @param expected_refs expected remote refs
Packit ae9e2a
 * @param expected_refs_len length of expected_refs
Packit ae9e2a
 */
Packit ae9e2a
void verify_remote_refs(const git_remote_head *actual_refs[], size_t actual_refs_len, const expected_ref expected_refs[], size_t expected_refs_len);
Packit ae9e2a
Packit ae9e2a
#endif /* INCLUDE_cl_push_util_h__ */