]> git.proxmox.com Git - libgit2.git/blobdiff - include/git2/remote.h
New upstream version 1.4.3+dfsg.1
[libgit2.git] / include / git2 / remote.h
index e9e4e5b6577aa64687990815edef44ffcd9217ea..8c9c26f3fd58b937e5cd1e7cd00ca6fdb500c2c7 100644 (file)
@@ -41,6 +41,104 @@ GIT_EXTERN(int) git_remote_create(
                const char *name,
                const char *url);
 
+/**
+ * Remote redirection settings; whether redirects to another host
+ * are permitted.  By default, git will follow a redirect on the
+ * initial request (`/info/refs`), but not subsequent requests.
+ */
+typedef enum {
+       /**
+        * Do not follow any off-site redirects at any stage of
+        * the fetch or push.
+        */
+       GIT_REMOTE_REDIRECT_NONE = (1 << 0),
+
+       /**
+        * Allow off-site redirects only upon the initial request.
+        * This is the default.
+        */
+       GIT_REMOTE_REDIRECT_INITIAL = (1 << 1),
+
+       /**
+        * Allow redirects at any stage in the fetch or push.
+        */
+       GIT_REMOTE_REDIRECT_ALL = (1 << 2)
+} git_remote_redirect_t;
+
+/**
+ * Remote creation options flags
+ */
+typedef enum {
+       /** Ignore the repository apply.insteadOf configuration */
+       GIT_REMOTE_CREATE_SKIP_INSTEADOF = (1 << 0),
+
+       /** Don't build a fetchspec from the name if none is set */
+       GIT_REMOTE_CREATE_SKIP_DEFAULT_FETCHSPEC = (1 << 1)
+} git_remote_create_flags;
+
+/**
+ * Remote creation options structure
+ *
+ * Initialize with `GIT_REMOTE_CREATE_OPTIONS_INIT`. Alternatively, you can
+ * use `git_remote_create_options_init`.
+ *
+ */
+typedef struct git_remote_create_options {
+       unsigned int version;
+
+       /**
+        * The repository that should own the remote.
+        * Setting this to NULL results in a detached remote.
+        */
+       git_repository *repository;
+
+       /**
+        * The remote's name.
+        * Setting this to NULL results in an in-memory/anonymous remote.
+        */
+       const char *name;
+
+       /** The fetchspec the remote should use. */
+       const char *fetchspec;
+
+       /** Additional flags for the remote. See git_remote_create_flags. */
+       unsigned int flags;
+} git_remote_create_options;
+
+#define GIT_REMOTE_CREATE_OPTIONS_VERSION 1
+#define GIT_REMOTE_CREATE_OPTIONS_INIT {GIT_REMOTE_CREATE_OPTIONS_VERSION}
+
+/**
+ * Initialize git_remote_create_options structure
+ *
+ * Initializes a `git_remote_create_options` with default values. Equivalent to
+ * creating an instance with `GIT_REMOTE_CREATE_OPTIONS_INIT`.
+ *
+ * @param opts The `git_remote_create_options` struct to initialize.
+ * @param version The struct version; pass `GIT_REMOTE_CREATE_OPTIONS_VERSION`.
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_remote_create_options_init(
+               git_remote_create_options *opts,
+               unsigned int version);
+
+/**
+ * Create a remote, with options.
+ *
+ * This function allows more fine-grained control over the remote creation.
+ *
+ * Passing NULL as the opts argument will result in a detached remote.
+ *
+ * @param out the resulting remote
+ * @param url the remote's url
+ * @param opts the remote creation options
+ * @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
+ */
+GIT_EXTERN(int) git_remote_create_with_opts(
+               git_remote **out,
+               const char *url,
+               const git_remote_create_options *opts);
+
 /**
  * Add a remote with the provided fetch refspec (or default if NULL) to the repository's
  * configuration.
@@ -75,6 +173,24 @@ GIT_EXTERN(int) git_remote_create_anonymous(
                git_repository *repo,
                const char *url);
 
+/**
+ * Create a remote without a connected local repo
+ *
+ * Create a remote with the given url in-memory. You can use this when
+ * you have a URL instead of a remote's name.
+ *
+ * Contrasted with git_remote_create_anonymous, a detached remote
+ * will not consider any repo configuration values (such as insteadof url
+ * substitutions).
+ *
+ * @param out pointer to the new remote objects
+ * @param url the remote repository's URL
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_remote_create_detached(
+               git_remote **out,
+               const char *url);
+
 /**
  * Get the information for a particular remote
  *
@@ -120,7 +236,8 @@ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
  * Get the remote's url
  *
  * If url.*.insteadOf has been configured for this URL, it will
- * return the modified URL.
+ * return the modified URL.  If `git_remote_set_instance_pushurl`
+ * has been called for this remote, then that URL will be returned.
  *
  * @param remote the remote
  * @return a pointer to the url
@@ -128,10 +245,11 @@ GIT_EXTERN(const char *) git_remote_name(const git_remote *remote);
 GIT_EXTERN(const char *) git_remote_url(const git_remote *remote);
 
 /**
- * Get the remote's url for pushing
+ * Get the remote's url for pushing.
  *
  * If url.*.pushInsteadOf has been configured for this URL, it
- * will return the modified URL.
+ * will return the modified URL.  If `git_remote_set_instance_pushurl`
+ * has been called for this remote, then that URL will be returned.
  *
  * @param remote the remote
  * @return a pointer to the url or NULL if no special url for pushing is set
@@ -149,7 +267,7 @@ GIT_EXTERN(const char *) git_remote_pushurl(const git_remote *remote);
  * @param url the url to set
  * @return 0 or an error value
  */
-GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, const charurl);
+GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, const char *url);
 
 /**
  * Set the remote's url for pushing in the configuration.
@@ -161,8 +279,29 @@ GIT_EXTERN(int) git_remote_set_url(git_repository *repo, const char *remote, con
  * @param repo the repository in which to perform the change
  * @param remote the remote's name
  * @param url the url to set
+ * @return 0, or an error code
+ */
+GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char *url);
+
+/**
+ * Set the url for this particular url instance.  The URL in the
+ * configuration will be ignored, and will not be changed.
+ *
+ * @param remote the remote's name
+ * @param url the url to set
+ * @return 0 or an error value
  */
-GIT_EXTERN(int) git_remote_set_pushurl(git_repository *repo, const char *remote, const char* url);
+GIT_EXTERN(int) git_remote_set_instance_url(git_remote *remote, const char *url);
+
+/**
+ * Set the push url for this particular url instance.  The URL in the
+ * configuration will be ignored, and will not be changed.
+ *
+ * @param remote the remote's name
+ * @param url the url to set
+ * @return 0 or an error value
+ */
+GIT_EXTERN(int) git_remote_set_instance_pushurl(git_remote *remote, const char *url);
 
 /**
  * Add a fetch refspec to the remote's configuration
@@ -185,6 +324,7 @@ GIT_EXTERN(int) git_remote_add_fetch(git_repository *repo, const char *remote, c
  *
  * @param array pointer to the array in which to store the strings
  * @param remote the remote to query
+ * @return 0 or an error code.
  */
 GIT_EXTERN(int) git_remote_get_fetch_refspecs(git_strarray *array, const git_remote *remote);
 
@@ -209,6 +349,7 @@ GIT_EXTERN(int) git_remote_add_push(git_repository *repo, const char *remote, co
  *
  * @param array pointer to the array in which to store the strings
  * @param remote the remote to query
+ * @return 0 or an error code.
  */
 GIT_EXTERN(int) git_remote_get_push_refspecs(git_strarray *array, const git_remote *remote);
 
@@ -229,23 +370,6 @@ GIT_EXTERN(size_t) git_remote_refspec_count(const git_remote *remote);
  */
 GIT_EXTERN(const git_refspec *)git_remote_get_refspec(const git_remote *remote, size_t n);
 
-/**
- * Open a connection to a remote
- *
- * The transport is selected based on the URL. The direction argument
- * is due to a limitation of the git protocol (over TCP or SSH) which
- * starts up a specific binary which can only do the one or the other.
- *
- * @param remote the remote to connect to
- * @param direction GIT_DIRECTION_FETCH if you want to fetch or
- * GIT_DIRECTION_PUSH if you want to push
- * @param callbacks the callbacks to use for this connection
- * @param proxy_opts proxy settings
- * @param custom_headers extra HTTP headers to use in this connection
- * @return 0 or an error code
- */
-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);
-
 /**
  * Get the remote repository's reference advertisement list
  *
@@ -286,8 +410,9 @@ GIT_EXTERN(int) git_remote_connected(const git_remote *remote);
  * the operation has been cancelled and if so stops the operation.
  *
  * @param remote the remote
+ * @return 0 on success, or an error code
  */
-GIT_EXTERN(void) git_remote_stop(git_remote *remote);
+GIT_EXTERN(int) git_remote_stop(git_remote *remote);
 
 /**
  * Disconnect from the remote
@@ -295,8 +420,9 @@ GIT_EXTERN(void) git_remote_stop(git_remote *remote);
  * Close the connection to the remote.
  *
  * @param remote the remote to disconnect from
+ * @return 0 on success, or an error code
  */
-GIT_EXTERN(void) git_remote_disconnect(git_remote *remote);
+GIT_EXTERN(int) git_remote_disconnect(git_remote *remote);
 
 /**
  * Free the memory associated with a remote
@@ -323,18 +449,19 @@ GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
  * Argument to the completion callback which tells it which operation
  * finished.
  */
-typedef enum git_remote_completion_type {
+typedef enum git_remote_completion_t {
        GIT_REMOTE_COMPLETION_DOWNLOAD,
        GIT_REMOTE_COMPLETION_INDEXING,
-       GIT_REMOTE_COMPLETION_ERROR,
-} git_remote_completion_type;
+       GIT_REMOTE_COMPLETION_ERROR
+} git_remote_completion_t;
 
 /** Push network progress notification function */
-typedef int (*git_push_transfer_progress)(
+typedef int GIT_CALLBACK(git_push_transfer_progress_cb)(
        unsigned int current,
        unsigned int total,
        size_t bytes,
-       void* payload);
+       void *payload);
+
 /**
  * Represents an update which will be performed on the remote during push
  */
@@ -365,7 +492,50 @@ typedef struct {
  * @param len number of elements in `updates`
  * @param payload Payload provided by the caller
  */
-typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len, void *payload);
+typedef int GIT_CALLBACK(git_push_negotiation)(const git_push_update **updates, size_t len, void *payload);
+
+/**
+ * Callback used to inform of the update status from the remote.
+ *
+ * Called for each updated reference on push. If `status` is
+ * not `NULL`, the update was rejected by the remote server
+ * and `status` contains the reason given.
+ *
+ * @param refname refname specifying to the remote ref
+ * @param status status message sent from the remote
+ * @param data data provided by the caller
+ * @return 0 on success, otherwise an error
+ */
+typedef int GIT_CALLBACK(git_push_update_reference_cb)(const char *refname, const char *status, void *data);
+
+#ifndef GIT_DEPRECATE_HARD
+/**
+ * Callback to resolve URLs before connecting to remote
+ *
+ * If you return GIT_PASSTHROUGH, you don't need to write anything to
+ * url_resolved.
+ *
+ * @param url_resolved The buffer to write the resolved URL to
+ * @param url The URL to resolve
+ * @param direction GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH
+ * @param payload Payload provided by the caller
+ * @return 0 on success, GIT_PASSTHROUGH or an error
+ * @deprecated Use `git_remote_set_instance_url`
+ */
+typedef int GIT_CALLBACK(git_url_resolve_cb)(git_buf *url_resolved, const char *url, int direction, void *payload);
+#endif
+
+/**
+ * Callback invoked immediately before we attempt to connect to the
+ * given url.  Callers may change the URL before the connection by
+ * calling `git_remote_set_instance_url` in the callback.
+ *
+ * @param remote The remote to be connected
+ * @param direction GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH
+ * @param payload Payload provided by the caller
+ * @return 0 on success, or an error
+ */
+typedef int GIT_CALLBACK(git_remote_ready_cb)(git_remote *remote, int direction, void *payload);
 
 /**
  * The callback settings structure
@@ -374,7 +544,8 @@ typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len,
  * about the progress of the network operations.
  */
 struct git_remote_callbacks {
-       unsigned int version;
+       unsigned int version; /**< The version */
+
        /**
         * Textual progress from the remote. Text send over the
         * progress side-band will be passed to this function (this is
@@ -386,7 +557,7 @@ struct git_remote_callbacks {
         * Completion is called when different parts of the download
         * process are done (currently unused).
         */
-       int (*completion)(git_remote_completion_type type, void *data);
+       int GIT_CALLBACK(completion)(git_remote_completion_t type, void *data);
 
        /**
         * This will be called if the remote host requires
@@ -395,13 +566,13 @@ struct git_remote_callbacks {
         * Returning GIT_PASSTHROUGH will make libgit2 behave as
         * though this field isn't set.
         */
-       git_cred_acquire_cb credentials;
+       git_credential_acquire_cb credentials;
 
        /**
         * If cert verification fails, this will be called to let the
         * user make the final decision of whether to allow the
-        * connection to proceed. Returns 1 to allow the connection, 0
-        * to disallow it or a negative value to indicate an error.
+        * connection to proceed. Returns 0 to allow the connection
+        * or a negative value to indicate an error.
         */
        git_transport_certificate_check_cb certificate_check;
 
@@ -410,13 +581,13 @@ struct git_remote_callbacks {
         * called with the current count of progress done by the
         * indexer.
         */
-       git_transfer_progress_cb transfer_progress;
+       git_indexer_progress_cb transfer_progress;
 
        /**
         * Each time a reference is updated locally, this function
         * will be called with information about it.
         */
-       int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
+       int GIT_CALLBACK(update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
 
        /**
         * Function to call with progress information during pack
@@ -431,14 +602,12 @@ struct git_remote_callbacks {
         * inline with pack building operations, so performance may be
         * affected.
         */
-       git_push_transfer_progress push_transfer_progress;
+       git_push_transfer_progress_cb push_transfer_progress;
 
        /**
-        * Called for each updated reference on push. If `status` is
-        * not `NULL`, the update was rejected by the remote server
-        * and `status` contains the reason given.
+        * See documentation of git_push_update_reference_cb
         */
-       int (*push_update_reference)(const char *refname, const char *status, void *data);
+       git_push_update_reference_cb push_update_reference;
 
        /**
         * Called once between the negotiation step and the upload. It
@@ -452,11 +621,29 @@ struct git_remote_callbacks {
         */
        git_transport_cb transport;
 
+       /**
+        * Callback when the remote is ready to connect.
+        */
+       git_remote_ready_cb remote_ready;
+
        /**
         * This will be passed to each of the callbacks in this struct
         * as the last parameter.
         */
        void *payload;
+
+#ifdef GIT_DEPRECATE_HARD
+       void *reserved;
+#else
+       /**
+        * Resolve URL before connecting to remote.
+        * The returned URL will be used to connect to the remote instead.
+        *
+        * This callback is deprecated; users should use
+        * git_remote_ready_cb and configure the instance URL instead.
+        */
+       git_url_resolve_cb resolve_url;
+#endif
 };
 
 #define GIT_REMOTE_CALLBACKS_VERSION 1
@@ -474,6 +661,7 @@ GIT_EXTERN(int) git_remote_init_callbacks(
        git_remote_callbacks *opts,
        unsigned int version);
 
+/** Acceptable prune settings when fetching */
 typedef enum {
        /**
         * Use the setting from the configuration
@@ -486,7 +674,7 @@ typedef enum {
        /**
         * Force pruning off
         */
-       GIT_FETCH_NO_PRUNE,
+       GIT_FETCH_NO_PRUNE
 } git_fetch_prune_t;
 
 /**
@@ -511,7 +699,7 @@ typedef enum {
        /**
         * Ask for the all the tags.
         */
-       GIT_REMOTE_DOWNLOAD_TAGS_ALL,
+       GIT_REMOTE_DOWNLOAD_TAGS_ALL
 } git_remote_autotag_option_t;
 
 /**
@@ -555,6 +743,13 @@ typedef struct {
         */
        git_proxy_options proxy_opts;
 
+       /**
+        * Whether to allow off-site redirects.  If this is not
+        * specified, the `http.followRedirects` configuration setting
+        * will be consulted.
+        */
+       git_remote_redirect_t follow_redirects;
+
        /**
         * Extra headers for this fetch operation
         */
@@ -566,15 +761,16 @@ typedef struct {
                                 GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT }
 
 /**
+ * Initialize git_fetch_options structure
+ *
  * Initializes a `git_fetch_options` with default values. Equivalent to
- * creating an instance with GIT_FETCH_OPTIONS_INIT.
+ * creating an instance with `GIT_FETCH_OPTIONS_INIT`.
  *
- * @param opts the `git_fetch_options` instance to initialize.
- * @param version the version of the struct; you should pass
- *        `GIT_FETCH_OPTIONS_VERSION` here.
+ * @param opts The `git_fetch_options` struct to initialize.
+ * @param version The struct version; pass `GIT_FETCH_OPTIONS_VERSION`.
  * @return Zero on success; -1 on failure.
  */
-GIT_EXTERN(int) git_fetch_init_options(
+GIT_EXTERN(int) git_fetch_options_init(
        git_fetch_options *opts,
        unsigned int version);
 
@@ -605,6 +801,13 @@ typedef struct {
        */
        git_proxy_options proxy_opts;
 
+       /**
+        * Whether to allow off-site redirects.  If this is not
+        * specified, the `http.followRedirects` configuration setting
+        * will be consulted.
+        */
+       git_remote_redirect_t follow_redirects;
+
        /**
         * Extra headers for this push operation
         */
@@ -612,23 +815,117 @@ typedef struct {
 } git_push_options;
 
 #define GIT_PUSH_OPTIONS_VERSION 1
-#define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 0, GIT_REMOTE_CALLBACKS_INIT, GIT_PROXY_OPTIONS_INIT }
+#define GIT_PUSH_OPTIONS_INIT { GIT_PUSH_OPTIONS_VERSION, 1, GIT_REMOTE_CALLBACKS_INIT, GIT_PROXY_OPTIONS_INIT }
 
 /**
+ * Initialize git_push_options structure
+ *
  * Initializes a `git_push_options` with default values. Equivalent to
- * creating an instance with GIT_PUSH_OPTIONS_INIT.
+ * creating an instance with `GIT_PUSH_OPTIONS_INIT`.
  *
- * @param opts the `git_push_options` instance to initialize.
- * @param version the version of the struct; you should pass
- *        `GIT_PUSH_OPTIONS_VERSION` here.
+ * @param opts The `git_push_options` struct to initialize.
+ * @param version The struct version; pass `GIT_PUSH_OPTIONS_VERSION`.
  * @return Zero on success; -1 on failure.
  */
-GIT_EXTERN(int) git_push_init_options(
+GIT_EXTERN(int) git_push_options_init(
        git_push_options *opts,
        unsigned int version);
 
 /**
- * Download and index the packfile
+ * Remote creation options structure
+ *
+ * Initialize with `GIT_REMOTE_CREATE_OPTIONS_INIT`. Alternatively, you can
+ * use `git_remote_create_options_init`.
+ *
+ */
+typedef struct {
+       unsigned int version;
+
+       /** Callbacks to use for this connection */
+       git_remote_callbacks callbacks;
+
+       /** HTTP Proxy settings */
+       git_proxy_options proxy_opts;
+
+       /**
+        * Whether to allow off-site redirects.  If this is not
+        * specified, the `http.followRedirects` configuration setting
+        * will be consulted.
+        */
+       git_remote_redirect_t follow_redirects;
+
+       /** Extra HTTP headers to use in this connection */
+       git_strarray custom_headers;
+} git_remote_connect_options;
+
+#define GIT_REMOTE_CONNECT_OPTIONS_VERSION 1
+#define GIT_REMOTE_CONNECT_OPTIONS_INIT { \
+       GIT_REMOTE_CONNECT_OPTIONS_VERSION, \
+       GIT_REMOTE_CALLBACKS_INIT, \
+       GIT_PROXY_OPTIONS_INIT }
+
+/**
+ * Initialize git_remote_connect_options structure.
+ *
+ * Initializes a `git_remote_connect_options` with default values.
+ * Equivalent to creating an instance with
+ * `GIT_REMOTE_CONNECT_OPTIONS_INIT`.
+ *
+ * @param opts The `git_remote_connect_options` struct to initialize.
+ * @param version The struct version; pass `GIT_REMOTE_CONNECT_OPTIONS_VERSION`.
+ * @return Zero on success; -1 on failure.
+ */
+GIT_EXTERN(int) git_remote_connect_options_init(
+               git_remote_connect_options *opts,
+               unsigned int version);
+
+/**
+ * Open a connection to a remote.
+ *
+ * The transport is selected based on the URL; the direction argument
+ * is due to a limitation of the git protocol which starts up a
+ * specific binary which can only do the one or the other.
+ *
+ * @param remote the remote to connect to
+ * @param direction GIT_DIRECTION_FETCH if you want to fetch or
+ * GIT_DIRECTION_PUSH if you want to push
+ * @param callbacks the callbacks to use for this connection
+ * @param proxy_opts proxy settings
+ * @param custom_headers extra HTTP headers to use in this connection
+ * @return 0 or an error code
+ */
+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);
+
+/**
+ * Open a connection to a remote with extended options.
+ *
+ * The transport is selected based on the URL; the direction argument
+ * is due to a limitation of the git protocol which starts up a
+ * specific binary which can only do the one or the other.
+ *
+ * The given options structure will form the defaults for connection
+ * options and callback setup.  Callers may override these defaults
+ * by specifying `git_fetch_options` or `git_push_options` in
+ * subsequent calls.
+ *
+ * @param remote the remote to connect to
+ * @param direction GIT_DIRECTION_FETCH if you want to fetch or
+ * GIT_DIRECTION_PUSH if you want to push
+ * @param opts the remote connection options
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_remote_connect_ext(
+       git_remote *remote,
+       git_direction direction,
+       const git_remote_connect_options *opts);
+
+/**
+ * Download and index the packfile.
  *
  * Connect to the remote if it hasn't been done yet, negotiate with
  * the remote git which objects are missing, download and index the
@@ -637,19 +934,31 @@ GIT_EXTERN(int) git_push_init_options(
  * The .idx file will be created and both it and the packfile with be
  * renamed to their final name.
  *
+ * If options are specified and this remote is already connected then
+ * the existing remote connection options will be discarded and the
+ * remote will now use the new options.
+ *
  * @param remote the remote
  * @param refspecs the refspecs to use for this negotiation and
  * download. Use NULL or an empty array to use the base refspecs
- * @param opts the options to use for this fetch
+ * @param opts the options to use for this fetch or NULL
  * @return 0 or an error code
  */
- GIT_EXTERN(int) git_remote_download(git_remote *remote, const git_strarray *refspecs, const git_fetch_options *opts);
+ GIT_EXTERN(int) git_remote_download(
+       git_remote *remote,
+       const git_strarray *refspecs,
+       const git_fetch_options *opts);
 
 /**
  * Create a packfile and send it to the server
  *
  * Connect to the remote if it hasn't been done yet, negotiate with
- * the remote git which objects are missing, create a packfile with the missing objects and send it.
+ * the remote git which objects are missing, create a packfile with
+ * the missing objects and send it.
+ *
+ * If options are specified and this remote is already connected then
+ * the existing remote connection options will be discarded and the
+ * remote will now use the new options.
  *
  * @param remote the remote
  * @param refspecs the refspecs to use for this negotiation and
@@ -657,17 +966,23 @@ GIT_EXTERN(int) git_push_init_options(
  * @param opts the options to use for this push
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts);
+GIT_EXTERN(int) git_remote_upload(
+       git_remote *remote,
+       const git_strarray *refspecs,
+       const git_push_options *opts);
 
 /**
- * Update the tips to the new state
+ * Update the tips to the new state.
+ *
+ * If callbacks are not specified then the callbacks specified to
+ * `git_remote_connect` will be used (if it was called).
  *
  * @param remote the remote to update
  * @param reflog_message The message to insert into the reflogs. If
  * NULL and fetching, the default is "fetch <name>", where <name> is
  * the name of the remote (or its url, for in-memory remotes). This
  * parameter is ignored when pushing.
- * @param callbacks  pointer to the callback structure to use
+ * @param callbacks  pointer to the callback structure to use or NULL
  * @param update_fetchhead whether to write to FETCH_HEAD. Pass 1 to behave like git.
  * @param download_tags what the behaviour for downloading tags is for this fetch. This is
  * ignored for push. This must be the same value passed to `git_remote_download()`.
@@ -681,15 +996,19 @@ GIT_EXTERN(int) git_remote_update_tips(
                const char *reflog_message);
 
 /**
- * Download new data and update tips
+ * Download new data and update tips.
  *
  * Convenience function to connect to a remote, download the data,
  * disconnect and update the remote-tracking branches.
  *
+ * If options are specified and this remote is already connected then
+ * the existing remote connection options will be discarded and the
+ * remote will now use the new options.
+ *
  * @param remote the remote to fetch from
  * @param refspecs the refspecs to use for this fetch. Pass NULL or an
  *                 empty array to use the base refspecs.
- * @param opts options to use for this fetch
+ * @param opts options to use for this fetch or NULL
  * @param reflog_message The message to insert into the reflogs. If NULL, the
  *                                                              default is "fetch"
  * @return 0 or an error code
@@ -701,32 +1020,41 @@ GIT_EXTERN(int) git_remote_fetch(
                const char *reflog_message);
 
 /**
- * Prune tracking refs that are no longer present on remote
+ * Prune tracking refs that are no longer present on remote.
+ *
+ * If callbacks are not specified then the callbacks specified to
+ * `git_remote_connect` will be used (if it was called).
  *
  * @param remote the remote to prune
  * @param callbacks callbacks to use for this prune
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_remote_prune(git_remote *remote, const git_remote_callbacks *callbacks);
+GIT_EXTERN(int) git_remote_prune(
+       git_remote *remote,
+       const git_remote_callbacks *callbacks);
 
 /**
- * Perform a push
+ * Perform a push.
  *
- * Peform all the steps from a push.
+ * If options are specified and this remote is already connected then
+ * the existing remote connection options will be discarded and the
+ * remote will now use the new options.
  *
  * @param remote the remote to push to
  * @param refspecs the refspecs to use for pushing. If NULL or an empty
  *                 array, the configured refspecs will be used
  * @param opts options to use for this push
+ * @return 0 or an error code.
  */
-GIT_EXTERN(int) git_remote_push(git_remote *remote,
-                               const git_strarray *refspecs,
-                               const git_push_options *opts);
+GIT_EXTERN(int) git_remote_push(
+       git_remote *remote,
+       const git_strarray *refspecs,
+       const git_push_options *opts);
 
 /**
  * Get the statistics structure that is filled in by the fetch operation.
  */
-GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
+GIT_EXTERN(const git_indexer_progress *) git_remote_stats(git_remote *remote);
 
 /**
  * Retrieve the tag auto-follow setting
@@ -745,8 +1073,10 @@ GIT_EXTERN(git_remote_autotag_option_t) git_remote_autotag(const git_remote *rem
  * @param repo the repository in which to make the change
  * @param remote the name of the remote
  * @param value the new value to take.
+ * @return 0, or an error code.
  */
 GIT_EXTERN(int) git_remote_set_autotag(git_repository *repo, const char *remote, git_remote_autotag_option_t value);
+
 /**
  * Retrieve the ref-prune setting
  *
@@ -784,10 +1114,11 @@ GIT_EXTERN(int) git_remote_rename(
 /**
  * Ensure the remote name is well-formed.
  *
+ * @param valid output pointer to set with validity of given remote name
  * @param remote_name name to be checked.
- * @return 1 if the reference name is acceptable; 0 if it isn't
+ * @return 0 on success or an error code
  */
-GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
+GIT_EXTERN(int) git_remote_name_is_valid(int *valid, const char *remote_name);
 
 /**
 * Delete an existing persisted remote.
@@ -812,7 +1143,7 @@ GIT_EXTERN(int) git_remote_delete(git_repository *repo, const char *name);
  *
  * This function must only be called after connecting.
  *
- * @param out the buffern in which to store the reference name
+ * @param out the buffer in which to store the reference name
  * @param remote the remote
  * @return 0, GIT_ENOTFOUND if the remote does not have any references
  * or none of them point to HEAD's commit, or an error message.