Blame src/push.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_push_h__
Packit Service 20376f
#define INCLUDE_push_h__
Packit Service 20376f
Packit Service 20376f
#include "git2.h"
Packit Service 20376f
#include "refspec.h"
Packit Service 20376f
Packit Service 20376f
typedef struct push_spec {
Packit Service 20376f
	struct git_refspec refspec;
Packit Service 20376f
Packit Service 20376f
	git_oid loid;
Packit Service 20376f
	git_oid roid;
Packit Service 20376f
} push_spec;
Packit Service 20376f
Packit Service 20376f
typedef struct push_status {
Packit Service 20376f
	bool ok;
Packit Service 20376f
Packit Service 20376f
	char *ref;
Packit Service 20376f
	char *msg;
Packit Service 20376f
} push_status;
Packit Service 20376f
Packit Service 20376f
struct git_push {
Packit Service 20376f
	git_repository *repo;
Packit Service 20376f
	git_packbuilder *pb;
Packit Service 20376f
	git_remote *remote;
Packit Service 20376f
	git_vector specs;
Packit Service 20376f
	git_vector updates;
Packit Service 20376f
	bool report_status;
Packit Service 20376f
Packit Service 20376f
	/* report-status */
Packit Service 20376f
	bool unpack_ok;
Packit Service 20376f
	git_vector status;
Packit Service 20376f
Packit Service 20376f
	/* options */
Packit Service 20376f
	unsigned pb_parallelism;
Packit Service 20376f
	const git_strarray *custom_headers;
Packit Service 20376f
};
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Free the given push status object
Packit Service 20376f
 *
Packit Service 20376f
 * @param status The push status object
Packit Service 20376f
 */
Packit Service 20376f
void git_push_status_free(push_status *status);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create a new push object
Packit Service 20376f
 *
Packit Service 20376f
 * @param out New push object
Packit Service 20376f
 * @param remote Remote instance
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
int git_push_new(git_push **out, git_remote *remote);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Set options on a push object
Packit Service 20376f
 *
Packit Service 20376f
 * @param push The push object
Packit Service 20376f
 * @param opts The options to set on the push object
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
int git_push_set_options(
Packit Service 20376f
	git_push *push,
Packit Service 20376f
	const git_push_options *opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Add a refspec to be pushed
Packit Service 20376f
 *
Packit Service 20376f
 * @param push The push object
Packit Service 20376f
 * @param refspec Refspec string
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
int git_push_add_refspec(git_push *push, const char *refspec);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Update remote tips after a push
Packit Service 20376f
 *
Packit Service 20376f
 * @param push The push object
Packit Service 20376f
 * @param callbacks the callbacks to use for this connection
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Perform the push
Packit Service 20376f
 *
Packit Service 20376f
 * This function will return an error in case of a protocol error or
Packit Service 20376f
 * the server being unable to unpack the data we sent.
Packit Service 20376f
 *
Packit Service 20376f
 * The return value does not reflect whether the server accepted or
Packit Service 20376f
 * refused any reference updates. Use `git_push_status_foreach()` in
Packit Service 20376f
 * order to find out which updates were accepted or rejected.
Packit Service 20376f
 *
Packit Service 20376f
 * @param push The push object
Packit Service 20376f
 * @param callbacks the callbacks to use for this connection
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
int git_push_finish(git_push *push, const git_remote_callbacks *callbacks);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Invoke callback `cb' on each status entry
Packit Service 20376f
 *
Packit Service 20376f
 * For each of the updated references, we receive a status report in the
Packit Service 20376f
 * form of `ok refs/heads/master` or `ng refs/heads/master <msg>`.
Packit Service 20376f
 * `msg != NULL` means the reference has not been updated for the given
Packit Service 20376f
 * reason.
Packit Service 20376f
 *
Packit Service 20376f
 * Return a non-zero value from the callback to stop the loop.
Packit Service 20376f
 *
Packit Service 20376f
 * @param push The push object
Packit Service 20376f
 * @param cb The callback to call on each object
Packit Service 20376f
 * @param data The payload passed to the callback
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 on success, non-zero callback return value, or error code
Packit Service 20376f
 */
Packit Service 20376f
int git_push_status_foreach(git_push *push,
Packit Service 20376f
			int (*cb)(const char *ref, const char *msg, void *data),
Packit Service 20376f
			void *data);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Free the given push object
Packit Service 20376f
 *
Packit Service 20376f
 * @param push The push object
Packit Service 20376f
 */
Packit Service 20376f
void git_push_free(git_push *push);
Packit Service 20376f
Packit Service 20376f
#endif