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