Blame include/git2/remote.h

Packit ae9e2a
/*
Packit ae9e2a
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit ae9e2a
 *
Packit ae9e2a
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit ae9e2a
 * a Linking Exception. For full terms see the included COPYING file.
Packit ae9e2a
 */
Packit ae9e2a
#ifndef INCLUDE_git_remote_h__
Packit ae9e2a
#define INCLUDE_git_remote_h__
Packit ae9e2a
Packit ae9e2a
#include "common.h"
Packit ae9e2a
#include "repository.h"
Packit ae9e2a
#include "refspec.h"
Packit ae9e2a
#include "net.h"
Packit ae9e2a
#include "indexer.h"
Packit ae9e2a
#include "strarray.h"
Packit ae9e2a
#include "transport.h"
Packit ae9e2a
#include "pack.h"
Packit ae9e2a
#include "proxy.h"
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * @file git2/remote.h
Packit ae9e2a
 * @brief Git remote management functions
Packit ae9e2a
 * @defgroup git_remote remote management functions
Packit ae9e2a
 * @ingroup Git
Packit ae9e2a
 * @{
Packit ae9e2a
 */
Packit ae9e2a
GIT_BEGIN_DECL
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Add a remote with the default fetch refspec to the repository's configuration.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out the resulting remote
Packit ae9e2a
 * @param repo the repository in which to create the remote
Packit ae9e2a
 * @param name the remote's name
Packit ae9e2a
 * @param url the remote's url
Packit ae9e2a
 * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_create(
Packit ae9e2a
		git_remote **out,
Packit ae9e2a
		git_repository *repo,
Packit ae9e2a
		const char *name,
Packit ae9e2a
		const char *url);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Add a remote with the provided fetch refspec (or default if NULL) to the repository's
Packit ae9e2a
 * configuration.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out the resulting remote
Packit ae9e2a
 * @param repo the repository in which to create the remote
Packit ae9e2a
 * @param name the remote's name
Packit ae9e2a
 * @param url the remote's url
Packit ae9e2a
 * @param fetch the remote fetch value
Packit ae9e2a
 * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_create_with_fetchspec(
Packit ae9e2a
		git_remote **out,
Packit ae9e2a
		git_repository *repo,
Packit ae9e2a
		const char *name,
Packit ae9e2a
		const char *url,
Packit ae9e2a
		const char *fetch);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create an anonymous remote
Packit ae9e2a
 *
Packit ae9e2a
 * Create a remote with the given url in-memory. You can use this when
Packit ae9e2a
 * you have a URL instead of a remote's name.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the new remote objects
Packit ae9e2a
 * @param repo the associated repository
Packit ae9e2a
 * @param url the remote repository's URL
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_create_anonymous(
Packit ae9e2a
		git_remote **out,
Packit ae9e2a
		git_repository *repo,
Packit ae9e2a
		const char *url);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the information for a particular remote
Packit ae9e2a
 *
Packit ae9e2a
 * The name will be checked for validity.
Packit ae9e2a
 * See `git_tag_create()` for rules about valid names.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the new remote object
Packit ae9e2a
 * @param repo the associated repository
Packit ae9e2a
 * @param name the remote's name
Packit ae9e2a
 * @return 0, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_lookup(git_remote **out, git_repository *repo, const char *name);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a copy of an existing remote.  All internal strings are also
Packit ae9e2a
 * duplicated. Callbacks are not duplicated.
Packit ae9e2a
 *
Packit ae9e2a
 * Call `git_remote_free` to free the data.
Packit ae9e2a
 *
Packit ae9e2a
 * @param dest pointer where to store the copy
Packit ae9e2a
 * @param source object to copy
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_dup(git_remote **dest, git_remote *source);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the remote's repository
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @return a pointer to the repository
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(git_repository *) git_remote_owner(const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the remote's name
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @return a pointer to the name or NULL for in-memory remotes
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the remote's url
Packit ae9e2a
 *
Packit ae9e2a
 * If url.*.insteadOf has been configured for this URL, it will
Packit ae9e2a
 * return the modified URL.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @return a pointer to the url
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const char *) git_remote_url(const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the remote's url for pushing
Packit ae9e2a
 *
Packit ae9e2a
 * If url.*.pushInsteadOf has been configured for this URL, it
Packit ae9e2a
 * will return the modified URL.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @return a pointer to the url or NULL if no special url for pushing is set
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Set the remote's url in the configuration
Packit ae9e2a
 *
Packit ae9e2a
 * Remote objects already in memory will not be affected. This assumes
Packit ae9e2a
 * the common case of a single-url remote and will otherwise return an error.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo the repository in which to perform the change
Packit ae9e2a
 * @param remote the remote's name
Packit ae9e2a
 * @param url the url to set
Packit ae9e2a
 * @return 0 or an error value
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, const char* url);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Set the remote's url for pushing in the configuration.
Packit ae9e2a
 *
Packit ae9e2a
 * Remote objects already in memory will not be affected. This assumes
Packit ae9e2a
 * the common case of a single-url remote and will otherwise return an error.
Packit ae9e2a
 *
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo the repository in which to perform the change
Packit ae9e2a
 * @param remote the remote's name
Packit ae9e2a
 * @param url the url to set
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Add a fetch refspec to the remote's configuration
Packit ae9e2a
 *
Packit ae9e2a
 * Add the given refspec to the fetch list in the configuration. No
Packit ae9e2a
 * loaded remote instances will be affected.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo the repository in which to change the configuration
Packit ae9e2a
 * @param remote the name of the remote to change
Packit ae9e2a
 * @param refspec the new fetch refspec
Packit ae9e2a
 * @return 0, GIT_EINVALIDSPEC if refspec is invalid or an error value
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_add_fetch(git_repository *repo, const char *remote, const char *refspec);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the remote's list of fetch refspecs
Packit ae9e2a
 *
Packit ae9e2a
 * The memory is owned by the user and should be freed with
Packit ae9e2a
 * `git_strarray_free`.
Packit ae9e2a
 *
Packit ae9e2a
 * @param array pointer to the array in which to store the strings
Packit ae9e2a
 * @param remote the remote to query
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Add a push refspec to the remote's configuration
Packit ae9e2a
 *
Packit ae9e2a
 * Add the given refspec to the push list in the configuration. No
Packit ae9e2a
 * loaded remote instances will be affected.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo the repository in which to change the configuration
Packit ae9e2a
 * @param remote the name of the remote to change
Packit ae9e2a
 * @param refspec the new push refspec
Packit ae9e2a
 * @return 0, GIT_EINVALIDSPEC if refspec is invalid or an error value
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_add_push(git_repository *repo, const char *remote, const char *refspec);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the remote's list of push refspecs
Packit ae9e2a
 *
Packit ae9e2a
 * The memory is owned by the user and should be freed with
Packit ae9e2a
 * `git_strarray_free`.
Packit ae9e2a
 *
Packit ae9e2a
 * @param array pointer to the array in which to store the strings
Packit ae9e2a
 * @param remote the remote to query
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the number of refspecs for a remote
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @return the amount of refspecs configured in this remote
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(size_t) git_remote_refspec_count(const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get a refspec from the remote
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to query
Packit ae9e2a
 * @param n the refspec to get
Packit ae9e2a
 * @return the nth refspec
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote, size_t n);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Open a connection to a remote
Packit ae9e2a
 *
Packit ae9e2a
 * The transport is selected based on the URL. The direction argument
Packit ae9e2a
 * is due to a limitation of the git protocol (over TCP or SSH) which
Packit ae9e2a
 * starts up a specific binary which can only do the one or the other.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to connect to
Packit ae9e2a
 * @param direction GIT_DIRECTION_FETCH if you want to fetch or
Packit ae9e2a
 * GIT_DIRECTION_PUSH if you want to push
Packit ae9e2a
 * @param callbacks the callbacks to use for this connection
Packit ae9e2a
 * @param proxy_opts proxy settings
Packit ae9e2a
 * @param custom_headers extra HTTP headers to use in this connection
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction, const git_remote_callbacks *callbacks, const git_proxy_options *proxy_opts, const git_strarray *custom_headers);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the remote repository's reference advertisement list
Packit ae9e2a
 *
Packit ae9e2a
 * Get the list of references with which the server responds to a new
Packit ae9e2a
 * connection.
Packit ae9e2a
 *
Packit ae9e2a
 * The remote (or more exactly its transport) must have connected to
Packit ae9e2a
 * the remote repository. This list is available as soon as the
Packit ae9e2a
 * connection to the remote is initiated and it remains available
Packit ae9e2a
 * after disconnecting.
Packit ae9e2a
 *
Packit ae9e2a
 * The memory belongs to the remote. The pointer will be valid as long
Packit ae9e2a
 * as a new connection is not initiated, but it is recommended that
Packit ae9e2a
 * you make a copy in order to make use of the data.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the array
Packit ae9e2a
 * @param size the number of remote heads
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @return 0 on success, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_ls(const git_remote_head ***out,  size_t *size, git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Check whether the remote is connected
Packit ae9e2a
 *
Packit ae9e2a
 * Check whether the remote's underlying transport is connected to the
Packit ae9e2a
 * remote host.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @return 1 if it's connected, 0 otherwise.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_connected(const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Cancel the operation
Packit ae9e2a
 *
Packit ae9e2a
 * At certain points in its operation, the network code checks whether
Packit ae9e2a
 * the operation has been cancelled and if so stops the operation.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_remote_stop(git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Disconnect from the remote
Packit ae9e2a
 *
Packit ae9e2a
 * Close the connection to the remote.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to disconnect from
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Free the memory associated with a remote
Packit ae9e2a
 *
Packit ae9e2a
 * This also disconnects from the remote, if the connection
Packit ae9e2a
 * has not been closed yet (using git_remote_disconnect).
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to free
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_remote_free(git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get a list of the configured remotes for a repo
Packit ae9e2a
 *
Packit ae9e2a
 * The string array must be freed by the user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out a string array which receives the names of the remotes
Packit ae9e2a
 * @param repo the repository to query
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Argument to the completion callback which tells it which operation
Packit ae9e2a
 * finished.
Packit ae9e2a
 */
Packit ae9e2a
typedef enum git_remote_completion_type {
Packit ae9e2a
	GIT_REMOTE_COMPLETION_DOWNLOAD,
Packit ae9e2a
	GIT_REMOTE_COMPLETION_INDEXING,
Packit ae9e2a
	GIT_REMOTE_COMPLETION_ERROR,
Packit ae9e2a
} git_remote_completion_type;
Packit ae9e2a
Packit ae9e2a
/** Push network progress notification function */
Packit ae9e2a
typedef int (*git_push_transfer_progress)(
Packit ae9e2a
	unsigned int current,
Packit ae9e2a
	unsigned int total,
Packit ae9e2a
	size_t bytes,
Packit ae9e2a
	void* payload);
Packit ae9e2a
/**
Packit ae9e2a
 * Represents an update which will be performed on the remote during push
Packit ae9e2a
 */
Packit ae9e2a
typedef struct {
Packit ae9e2a
	/**
Packit ae9e2a
	 * The source name of the reference
Packit ae9e2a
	 */
Packit ae9e2a
	char *src_refname;
Packit ae9e2a
	/**
Packit ae9e2a
	 * The name of the reference to update on the server
Packit ae9e2a
	 */
Packit ae9e2a
	char *dst_refname;
Packit ae9e2a
	/**
Packit ae9e2a
	 * The current target of the reference
Packit ae9e2a
	 */
Packit ae9e2a
	git_oid src;
Packit ae9e2a
	/**
Packit ae9e2a
	 * The new target for the reference
Packit ae9e2a
	 */
Packit ae9e2a
	git_oid dst;
Packit ae9e2a
} git_push_update;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Callback used to inform of upcoming updates.
Packit ae9e2a
 *
Packit ae9e2a
 * @param updates an array containing the updates which will be sent
Packit ae9e2a
 * as commands to the destination.
Packit ae9e2a
 * @param len number of elements in `updates`
Packit ae9e2a
 * @param payload Payload provided by the caller
Packit ae9e2a
 */
Packit ae9e2a
typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len, void *payload);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * The callback settings structure
Packit ae9e2a
 *
Packit ae9e2a
 * Set the callbacks to be called by the remote when informing the user
Packit ae9e2a
 * about the progress of the network operations.
Packit ae9e2a
 */
Packit ae9e2a
struct git_remote_callbacks {
Packit ae9e2a
	unsigned int version;
Packit ae9e2a
	/**
Packit ae9e2a
	 * Textual progress from the remote. Text send over the
Packit ae9e2a
	 * progress side-band will be passed to this function (this is
Packit ae9e2a
	 * the 'counting objects' output).
Packit ae9e2a
	 */
Packit ae9e2a
	git_transport_message_cb sideband_progress;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Completion is called when different parts of the download
Packit ae9e2a
	 * process are done (currently unused).
Packit ae9e2a
	 */
Packit ae9e2a
	int (*completion)(git_remote_completion_type type, void *data);
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * This will be called if the remote host requires
Packit ae9e2a
	 * authentication in order to connect to it.
Packit ae9e2a
	 *
Packit ae9e2a
	 * Returning GIT_PASSTHROUGH will make libgit2 behave as
Packit ae9e2a
	 * though this field isn't set.
Packit ae9e2a
	 */
Packit ae9e2a
	git_cred_acquire_cb credentials;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * If cert verification fails, this will be called to let the
Packit ae9e2a
	 * user make the final decision of whether to allow the
Packit ae9e2a
	 * connection to proceed. Returns 1 to allow the connection, 0
Packit ae9e2a
	 * to disallow it or a negative value to indicate an error.
Packit ae9e2a
	 */
Packit ae9e2a
	git_transport_certificate_check_cb certificate_check;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * During the download of new data, this will be regularly
Packit ae9e2a
	 * called with the current count of progress done by the
Packit ae9e2a
	 * indexer.
Packit ae9e2a
	 */
Packit ae9e2a
	git_transfer_progress_cb transfer_progress;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Each time a reference is updated locally, this function
Packit ae9e2a
	 * will be called with information about it.
Packit ae9e2a
	 */
Packit ae9e2a
	int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Function to call with progress information during pack
Packit ae9e2a
	 * building. Be aware that this is called inline with pack
Packit ae9e2a
	 * building operations, so performance may be affected.
Packit ae9e2a
	 */
Packit ae9e2a
	git_packbuilder_progress pack_progress;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Function to call with progress information during the
Packit ae9e2a
	 * upload portion of a push. Be aware that this is called
Packit ae9e2a
	 * inline with pack building operations, so performance may be
Packit ae9e2a
	 * affected.
Packit ae9e2a
	 */
Packit ae9e2a
	git_push_transfer_progress push_transfer_progress;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Called for each updated reference on push. If `status` is
Packit ae9e2a
	 * not `NULL`, the update was rejected by the remote server
Packit ae9e2a
	 * and `status` contains the reason given.
Packit ae9e2a
	 */
Packit ae9e2a
	int (*push_update_reference)(const char *refname, const char *status, void *data);
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Called once between the negotiation step and the upload. It
Packit ae9e2a
	 * provides information about what updates will be performed.
Packit ae9e2a
	 */
Packit ae9e2a
	git_push_negotiation push_negotiation;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Create the transport to use for this operation. Leave NULL
Packit ae9e2a
	 * to auto-detect.
Packit ae9e2a
	 */
Packit ae9e2a
	git_transport_cb transport;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * This will be passed to each of the callbacks in this struct
Packit ae9e2a
	 * as the last parameter.
Packit ae9e2a
	 */
Packit ae9e2a
	void *payload;
Packit ae9e2a
};
Packit ae9e2a
Packit ae9e2a
#define GIT_REMOTE_CALLBACKS_VERSION 1
Packit ae9e2a
#define GIT_REMOTE_CALLBACKS_INIT {GIT_REMOTE_CALLBACKS_VERSION}
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Initializes a `git_remote_callbacks` with default values. Equivalent to
Packit ae9e2a
 * creating an instance with GIT_REMOTE_CALLBACKS_INIT.
Packit ae9e2a
 *
Packit ae9e2a
 * @param opts the `git_remote_callbacks` struct to initialize
Packit ae9e2a
 * @param version Version of struct; pass `GIT_REMOTE_CALLBACKS_VERSION`
Packit ae9e2a
 * @return Zero on success; -1 on failure.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_init_callbacks(
Packit ae9e2a
	git_remote_callbacks *opts,
Packit ae9e2a
	unsigned int version);
Packit ae9e2a
Packit ae9e2a
typedef enum {
Packit ae9e2a
	/**
Packit ae9e2a
	 * Use the setting from the configuration
Packit ae9e2a
	 */
Packit ae9e2a
	GIT_FETCH_PRUNE_UNSPECIFIED,
Packit ae9e2a
	/**
Packit ae9e2a
	 * Force pruning on
Packit ae9e2a
	 */
Packit ae9e2a
	GIT_FETCH_PRUNE,
Packit ae9e2a
	/**
Packit ae9e2a
	 * Force pruning off
Packit ae9e2a
	 */
Packit ae9e2a
	GIT_FETCH_NO_PRUNE,
Packit ae9e2a
} git_fetch_prune_t;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Automatic tag following option
Packit ae9e2a
 *
Packit ae9e2a
 * Lets us select the --tags option to use.
Packit ae9e2a
 */
Packit ae9e2a
typedef enum {
Packit ae9e2a
	/**
Packit ae9e2a
	 * Use the setting from the configuration.
Packit ae9e2a
	 */
Packit ae9e2a
	GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED = 0,
Packit ae9e2a
	/**
Packit ae9e2a
	 * Ask the server for tags pointing to objects we're already
Packit ae9e2a
	 * downloading.
Packit ae9e2a
	 */
Packit ae9e2a
	GIT_REMOTE_DOWNLOAD_TAGS_AUTO,
Packit ae9e2a
	/**
Packit ae9e2a
	 * Don't ask for any tags beyond the refspecs.
Packit ae9e2a
	 */
Packit ae9e2a
	GIT_REMOTE_DOWNLOAD_TAGS_NONE,
Packit ae9e2a
	/**
Packit ae9e2a
	 * Ask for the all the tags.
Packit ae9e2a
	 */
Packit ae9e2a
	GIT_REMOTE_DOWNLOAD_TAGS_ALL,
Packit ae9e2a
} git_remote_autotag_option_t;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Fetch options structure.
Packit ae9e2a
 *
Packit ae9e2a
 * Zero out for defaults.  Initialize with `GIT_FETCH_OPTIONS_INIT` macro to
Packit ae9e2a
 * correctly set the `version` field.  E.g.
Packit ae9e2a
 *
Packit ae9e2a
 *		git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
Packit ae9e2a
 */
Packit ae9e2a
typedef struct {
Packit ae9e2a
	int version;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Callbacks to use for this fetch operation
Packit ae9e2a
	 */
Packit ae9e2a
	git_remote_callbacks callbacks;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Whether to perform a prune after the fetch
Packit ae9e2a
	 */
Packit ae9e2a
	git_fetch_prune_t prune;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Whether to write the results to FETCH_HEAD. Defaults to
Packit ae9e2a
	 * on. Leave this default in order to behave like git.
Packit ae9e2a
	 */
Packit ae9e2a
	int update_fetchhead;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Determines how to behave regarding tags on the remote, such
Packit ae9e2a
	 * as auto-downloading tags for objects we're downloading or
Packit ae9e2a
	 * downloading all of them.
Packit ae9e2a
	 *
Packit ae9e2a
	 * The default is to auto-follow tags.
Packit ae9e2a
	 */
Packit ae9e2a
	git_remote_autotag_option_t download_tags;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Proxy options to use, by default no proxy is used.
Packit ae9e2a
	 */
Packit ae9e2a
	git_proxy_options proxy_opts;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Extra headers for this fetch operation
Packit ae9e2a
	 */
Packit ae9e2a
	git_strarray custom_headers;
Packit ae9e2a
} git_fetch_options;
Packit ae9e2a
Packit ae9e2a
#define GIT_FETCH_OPTIONS_VERSION 1
Packit ae9e2a
#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1, \
Packit ae9e2a
				 GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT }
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Initializes a `git_fetch_options` with default values. Equivalent to
Packit ae9e2a
 * creating an instance with GIT_FETCH_OPTIONS_INIT.
Packit ae9e2a
 *
Packit ae9e2a
 * @param opts the `git_fetch_options` instance to initialize.
Packit ae9e2a
 * @param version the version of the struct; you should pass
Packit ae9e2a
 *        `GIT_FETCH_OPTIONS_VERSION` here.
Packit ae9e2a
 * @return Zero on success; -1 on failure.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_fetch_init_options(
Packit ae9e2a
	git_fetch_options *opts,
Packit ae9e2a
	unsigned int version);
Packit ae9e2a
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Controls the behavior of a git_push object.
Packit ae9e2a
 */
Packit ae9e2a
typedef struct {
Packit ae9e2a
	unsigned int version;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * If the transport being used to push to the remote requires the creation
Packit ae9e2a
	 * of a pack file, this controls the number of worker threads used by
Packit ae9e2a
	 * the packbuilder when creating that pack file to be sent to the remote.
Packit ae9e2a
	 *
Packit ae9e2a
	 * If set to 0, the packbuilder will auto-detect the number of threads
Packit ae9e2a
	 * to create. The default value is 1.
Packit ae9e2a
	 */
Packit ae9e2a
	unsigned int pb_parallelism;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Callbacks to use for this push operation
Packit ae9e2a
	 */
Packit ae9e2a
	git_remote_callbacks callbacks;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	* Proxy options to use, by default no proxy is used.
Packit ae9e2a
	*/
Packit ae9e2a
	git_proxy_options proxy_opts;
Packit ae9e2a
Packit ae9e2a
	/**
Packit ae9e2a
	 * Extra headers for this push operation
Packit ae9e2a
	 */
Packit ae9e2a
	git_strarray custom_headers;
Packit ae9e2a
} git_push_options;
Packit ae9e2a
Packit ae9e2a
#define GIT_PUSH_OPTIONS_VERSION 1
Packit ae9e2a
#define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT, GIT_PROXY_OPTIONS_INIT }
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Initializes a `git_push_options` with default values. Equivalent to
Packit ae9e2a
 * creating an instance with GIT_PUSH_OPTIONS_INIT.
Packit ae9e2a
 *
Packit ae9e2a
 * @param opts the `git_push_options` instance to initialize.
Packit ae9e2a
 * @param version the version of the struct; you should pass
Packit ae9e2a
 *        `GIT_PUSH_OPTIONS_VERSION` here.
Packit ae9e2a
 * @return Zero on success; -1 on failure.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_push_init_options(
Packit ae9e2a
	git_push_options *opts,
Packit ae9e2a
	unsigned int version);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Download and index the packfile
Packit ae9e2a
 *
Packit ae9e2a
 * Connect to the remote if it hasn't been done yet, negotiate with
Packit ae9e2a
 * the remote git which objects are missing, download and index the
Packit ae9e2a
 * packfile.
Packit ae9e2a
 *
Packit ae9e2a
 * The .idx file will be created and both it and the packfile with be
Packit ae9e2a
 * renamed to their final name.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @param refspecs the refspecs to use for this negotiation and
Packit ae9e2a
 * download. Use NULL or an empty array to use the base refspecs
Packit ae9e2a
 * @param opts the options to use for this fetch
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
 GIT_EXTERN(int) git_remote_download(git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a packfile and send it to the server
Packit ae9e2a
 *
Packit ae9e2a
 * Connect to the remote if it hasn't been done yet, negotiate with
Packit ae9e2a
 * the remote git which objects are missing, create a packfile with the missing objects and send it.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @param refspecs the refspecs to use for this negotiation and
Packit ae9e2a
 * upload. Use NULL or an empty array to use the base refspecs
Packit ae9e2a
 * @param opts the options to use for this push
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Update the tips to the new state
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to update
Packit ae9e2a
 * @param reflog_message The message to insert into the reflogs. If
Packit ae9e2a
 * NULL and fetching, the default is "fetch <name>", where <name> is
Packit ae9e2a
 * the name of the remote (or its url, for in-memory remotes). This
Packit ae9e2a
 * parameter is ignored when pushing.
Packit ae9e2a
 * @param callbacks  pointer to the callback structure to use
Packit ae9e2a
 * @param update_fetchhead whether to write to FETCH_HEAD. Pass 1 to behave like git.
Packit ae9e2a
 * @param download_tags what the behaviour for downloading tags is for this fetch. This is
Packit ae9e2a
 * ignored for push. This must be the same value passed to `git_remote_download()`.
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_update_tips(
Packit ae9e2a
		git_remote *remote,
Packit ae9e2a
		const git_remote_callbacks *callbacks,
Packit ae9e2a
		int update_fetchhead,
Packit ae9e2a
		git_remote_autotag_option_t download_tags,
Packit ae9e2a
		const char *reflog_message);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Download new data and update tips
Packit ae9e2a
 *
Packit ae9e2a
 * Convenience function to connect to a remote, download the data,
Packit ae9e2a
 * disconnect and update the remote-tracking branches.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to fetch from
Packit ae9e2a
 * @param refspecs the refspecs to use for this fetch. Pass NULL or an
Packit ae9e2a
 *                 empty array to use the base refspecs.
Packit ae9e2a
 * @param opts options to use for this fetch
Packit ae9e2a
 * @param reflog_message The message to insert into the reflogs. If NULL, the
Packit ae9e2a
 *								 default is "fetch"
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_fetch(
Packit ae9e2a
		git_remote *remote,
Packit ae9e2a
		const git_strarray *refspecs,
Packit ae9e2a
		const git_fetch_options *opts,
Packit ae9e2a
		const char *reflog_message);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Prune tracking refs that are no longer present on remote
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to prune
Packit ae9e2a
 * @param callbacks callbacks to use for this prune
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Perform a push
Packit ae9e2a
 *
Packit ae9e2a
 * Peform all the steps from a push.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to push to
Packit ae9e2a
 * @param refspecs the refspecs to use for pushing. If NULL or an empty
Packit ae9e2a
 *                 array, the configured refspecs will be used
Packit ae9e2a
 * @param opts options to use for this push
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_push(git_remote *remote,
Packit ae9e2a
				const git_strarray *refspecs,
Packit ae9e2a
				const git_push_options *opts);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the statistics structure that is filled in by the fetch operation.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Retrieve the tag auto-follow setting
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to query
Packit ae9e2a
 * @return the auto-follow setting
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Set the remote's tag following setting.
Packit ae9e2a
 *
Packit ae9e2a
 * The change will be made in the configuration. No loaded remotes
Packit ae9e2a
 * will be affected.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo the repository in which to make the change
Packit ae9e2a
 * @param remote the name of the remote
Packit ae9e2a
 * @param value the new value to take.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value);
Packit ae9e2a
/**
Packit ae9e2a
 * Retrieve the ref-prune setting
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote the remote to query
Packit ae9e2a
 * @return the ref-prune setting
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_prune_refs(const git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Give the remote a new name
Packit ae9e2a
 *
Packit ae9e2a
 * All remote-tracking branches and configuration settings
Packit ae9e2a
 * for the remote are updated.
Packit ae9e2a
 *
Packit ae9e2a
 * The new name will be checked for validity.
Packit ae9e2a
 * See `git_tag_create()` for rules about valid names.
Packit ae9e2a
 *
Packit ae9e2a
 * No loaded instances of a the remote with the old name will change
Packit ae9e2a
 * their name or their list of refspecs.
Packit ae9e2a
 *
Packit ae9e2a
 * @param problems non-default refspecs cannot be renamed and will be
Packit ae9e2a
 * stored here for further processing by the caller. Always free this
Packit ae9e2a
 * strarray on successful return.
Packit ae9e2a
 * @param repo the repository in which to rename
Packit ae9e2a
 * @param name the current name of the remote
Packit ae9e2a
 * @param new_name the new name the remote should bear
Packit ae9e2a
 * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_rename(
Packit ae9e2a
	git_strarray *problems,
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	const char *name,
Packit ae9e2a
	const char *new_name);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Ensure the remote name is well-formed.
Packit ae9e2a
 *
Packit ae9e2a
 * @param remote_name name to be checked.
Packit ae9e2a
 * @return 1 if the reference name is acceptable; 0 if it isn't
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
* Delete an existing persisted remote.
Packit ae9e2a
*
Packit ae9e2a
* All remote-tracking branches and configuration settings
Packit ae9e2a
* for the remote will be removed.
Packit ae9e2a
*
Packit ae9e2a
* @param repo the repository in which to act
Packit ae9e2a
* @param name the name of the remote to delete
Packit ae9e2a
* @return 0 on success, or an error code.
Packit ae9e2a
*/
Packit ae9e2a
GIT_EXTERN(int) git_remote_delete(git_repository *repo, const char *name);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Retrieve the name of the remote's default branch
Packit ae9e2a
 *
Packit ae9e2a
 * The default branch of a repository is the branch which HEAD points
Packit ae9e2a
 * to. If the remote does not support reporting this information
Packit ae9e2a
 * directly, it performs the guess as git does; that is, if there are
Packit ae9e2a
 * multiple branches which point to the same commit, the first one is
Packit ae9e2a
 * chosen. If the master branch is a candidate, it wins.
Packit ae9e2a
 *
Packit ae9e2a
 * This function must only be called after connecting.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out the buffern in which to store the reference name
Packit ae9e2a
 * @param remote the remote
Packit ae9e2a
 * @return 0, GIT_ENOTFOUND if the remote does not have any references
Packit ae9e2a
 * or none of them point to HEAD's commit, or an error message.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_remote_default_branch(git_buf *out, git_remote *remote);
Packit ae9e2a
Packit ae9e2a
/** @} */
Packit ae9e2a
GIT_END_DECL
Packit ae9e2a
#endif