From d31402a3fc4aa1b7d48ba43fd3bb072e7d69a527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 16 Sep 2013 04:20:05 +0200 Subject: remote: put the _download() callback with the others The text progress and update_tips callbacks are already part of the struct, which was meant to unify the callback setup, but the download one was left out. --- include/git2/clone.h | 2 -- include/git2/remote.h | 11 ++--------- 2 files changed, 2 insertions(+), 11 deletions(-) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index 580352ac1..122806ad5 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -69,8 +69,6 @@ typedef struct git_clone_options { git_checkout_opts checkout_opts; git_repository_init_options *init_options; int bare; - git_transfer_progress_callback fetch_progress_cb; - void *fetch_progress_payload; const char *remote_name; const char *pushurl; diff --git a/include/git2/remote.h b/include/git2/remote.h index fa8b378c6..2bde5e365 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -257,17 +257,9 @@ GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void * The .idx file will be created and both it and the packfile with be * renamed to their final name. * - * @param remote the remote to download from - * @param progress_cb function to call with progress information. Be aware that - * this is called inline with network and indexing operations, so performance - * may be affected. - * @param payload payload for the progress callback * @return 0 or an error code */ -GIT_EXTERN(int) git_remote_download( - git_remote *remote, - git_transfer_progress_callback progress_cb, - void *payload); +GIT_EXTERN(int) git_remote_download(git_remote *remote); /** * Check whether the remote is connected @@ -403,6 +395,7 @@ struct git_remote_callbacks { unsigned int version; void (*progress)(const char *str, int len, void *data); int (*completion)(git_remote_completion_type type, void *data); + int (*transfer_progress)(const git_transfer_progress *stats, void *data); int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data); void *payload; }; -- cgit v1.2.1 From e3c131c544bc79573ebefab4931b5ca89836ace1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 16 Sep 2013 05:02:25 +0200 Subject: remote: move the credentials callback to the struct Move this one as well, letting us have a single way of setting the callbacks for the remote, and removing fields from the clone options. --- include/git2/clone.h | 5 ----- include/git2/remote.h | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index 122806ad5..38c759f6e 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -48,9 +48,6 @@ GIT_BEGIN_DECL * results in the same behavior as GIT_REMOTE_DEFAULT_FETCH. * - `push_spec` is the fetch specification to be used for pushing. NULL means * use the same spec as for fetching. - * - `cred_acquire_cb` is a callback to be used if credentials are required - * during the initial fetch. - * - `cred_acquire_payload` is the payload for the above callback. * - `transport_flags` is flags used to create transport if no transport is * provided. * - `transport` is a custom transport to be used for the initial fetch. NULL @@ -74,8 +71,6 @@ typedef struct git_clone_options { const char *pushurl; const char *fetch_spec; const char *push_spec; - git_cred_acquire_cb cred_acquire_cb; - void *cred_acquire_payload; git_transport_flags_t transport_flags; git_transport *transport; git_remote_callbacks *remote_callbacks; diff --git a/include/git2/remote.h b/include/git2/remote.h index 2bde5e365..83ad195f4 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -395,6 +395,7 @@ struct git_remote_callbacks { unsigned int version; void (*progress)(const char *str, int len, void *data); int (*completion)(git_remote_completion_type type, void *data); + int (*credentials)(git_cred **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *data); int (*transfer_progress)(const git_transfer_progress *stats, void *data); int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data); void *payload; -- cgit v1.2.1 From d19870d947eef17008ae0b4b7ebc9e9d0038a770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 16 Sep 2013 05:10:55 +0200 Subject: clone: implement git_clone_into This allows you to set up the repository and remote as you which to have them before performing the clone operation. --- include/git2/clone.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index 38c759f6e..c3936f6b0 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -99,6 +99,22 @@ GIT_EXTERN(int) git_clone( const char *local_path, const git_clone_options *options); +/** + * Clone into a repository + * + * After creating the repository and remote and configuring them for + * paths and callbacks respectively, you can call this function to + * perform the clone operation and optionally checkout files. + * + * @param repo the repository to use + * @param remote the remote repository to clone from + * @param co_opts options to use during checkout + * @param branch the branch to checkout after the clone, pass NULL for the remote's + * default branch + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_clone_into(git_repository *repo, git_remote *remote, git_checkout_opts *co_opts, const char *branch); + /** @} */ GIT_END_DECL #endif -- cgit v1.2.1 From fe3a40a4ff056400cde6e456211d6b5f2ec1008e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 16 Sep 2013 16:54:37 +0200 Subject: remote: add a convenience 'fetch' function. --- include/git2/remote.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/git2') diff --git a/include/git2/remote.h b/include/git2/remote.h index 83ad195f4..8c21870de 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -310,6 +310,17 @@ GIT_EXTERN(void) git_remote_free(git_remote *remote); */ GIT_EXTERN(int) git_remote_update_tips(git_remote *remote); +/** + * Download new data and update tips + * + * Convenience function to connect to a remote, download the data, + * disconnect and update the remote-tracking branches. + * + * @param remote the remote to fetch from + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_fetch(git_remote *remote); + /** * Return whether a string is a valid remote URL * -- cgit v1.2.1 From c8dbec4803aa7d8300f19a97431bbf631ac5a392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 16 Sep 2013 18:42:53 +0200 Subject: clone: remove the autotag option Downloading all tags is part of what makes it a clone instead of simply a fetch. --- include/git2/clone.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index c3936f6b0..c80bf9baa 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -54,8 +54,6 @@ GIT_BEGIN_DECL * means use the transport autodetected from the URL. * - `remote_callbacks` may be used to specify custom progress callbacks for * the origin remote before the fetch is initiated. - * - `remote_autotag` may be used to specify the autotag setting before the - * initial fetch. The default is GIT_REMOTE_DOWNLOAD_TAGS_ALL. * - `checkout_branch` gives the name of the branch to checkout. NULL means * use the remote's HEAD. */ @@ -74,7 +72,6 @@ typedef struct git_clone_options { git_transport_flags_t transport_flags; git_transport *transport; git_remote_callbacks *remote_callbacks; - git_remote_autotag_option_t remote_autotag; const char* checkout_branch; } git_clone_options; -- cgit v1.2.1 From 6ac15eff6d173674d9f17e9d5ddb98997eb97cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 20 Sep 2013 22:34:05 +0200 Subject: clone: remove more options from basic clone The basic clone function is there to make it easy to create a "normal" clone. Remove a bunch of options that are about changing the remote's configuration. --- include/git2/clone.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index c80bf9baa..0a89b5712 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -62,15 +62,8 @@ typedef struct git_clone_options { unsigned int version; git_checkout_opts checkout_opts; - git_repository_init_options *init_options; int bare; - const char *remote_name; - const char *pushurl; - const char *fetch_spec; - const char *push_spec; - git_transport_flags_t transport_flags; - git_transport *transport; git_remote_callbacks *remote_callbacks; const char* checkout_branch; } git_clone_options; -- cgit v1.2.1 From b9bf5d701dd6dfcfcb41d2655f59f7669cd50ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 20 Sep 2013 22:46:32 +0200 Subject: clone: re-add a way to ignore certificate errors This used to be done via transport flags, which was removed in a previous commit. --- include/git2/clone.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index 0a89b5712..cf759ab5c 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -63,6 +63,7 @@ typedef struct git_clone_options { git_checkout_opts checkout_opts; int bare; + int ignore_cert_errors; git_remote_callbacks *remote_callbacks; const char* checkout_branch; -- cgit v1.2.1 From eec1c1fe1e9a12b57c4014be25ce4ed390c8e199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 20 Sep 2013 22:49:20 +0200 Subject: clone: const-ify checkout options The removal of many options which lead to the direct usage of the user's checkout options means we should make sure they remain const. --- include/git2/checkout.h | 2 +- include/git2/clone.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include/git2') diff --git a/include/git2/checkout.h b/include/git2/checkout.h index aa48069cd..844f0a9e2 100644 --- a/include/git2/checkout.h +++ b/include/git2/checkout.h @@ -255,7 +255,7 @@ typedef struct git_checkout_opts { */ GIT_EXTERN(int) git_checkout_head( git_repository *repo, - git_checkout_opts *opts); + const git_checkout_opts *opts); /** * Updates files in the working tree to match the content of the index. diff --git a/include/git2/clone.h b/include/git2/clone.h index cf759ab5c..a59de1bc7 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -104,7 +104,7 @@ GIT_EXTERN(int) git_clone( * default branch * @return 0 on success or an error code */ -GIT_EXTERN(int) git_clone_into(git_repository *repo, git_remote *remote, git_checkout_opts *co_opts, const char *branch); +GIT_EXTERN(int) git_clone_into(git_repository *repo, git_remote *remote, const git_checkout_opts *co_opts, const char *branch); /** @} */ GIT_END_DECL -- cgit v1.2.1 From c833893c64d28d4c017fdbf90bbeb714314a8dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 20 Sep 2013 22:57:01 +0200 Subject: clone: re-allow using a custom remote name This is a small thing that by itself doesn't quite justify making the user use clone_into. --- include/git2/clone.h | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index a59de1bc7..bd602fb7a 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -35,25 +35,12 @@ GIT_BEGIN_DECL * set the `checkout_strategy` to GIT_CHECKOUT_DEFAULT. * - `bare` should be set to zero to create a standard repo, non-zero for * a bare repo - * - `fetch_progress_cb` is optional callback for fetch progress. Be aware that - * this is called inline with network and indexing operations, so performance - * may be affected. - * - `fetch_progress_payload` is payload for fetch_progress_cb + * - `ignore_cert_errors` should be set to 1 if errors validating the remote host's + * certificate should be ignored. * * ** "origin" remote options: ** * - `remote_name` is the name given to the "origin" remote. The default is * "origin". - * - `pushurl` is a URL to be used for pushing. NULL means use the fetch url. - * - `fetch_spec` is the fetch specification to be used for fetching. NULL - * results in the same behavior as GIT_REMOTE_DEFAULT_FETCH. - * - `push_spec` is the fetch specification to be used for pushing. NULL means - * use the same spec as for fetching. - * - `transport_flags` is flags used to create transport if no transport is - * provided. - * - `transport` is a custom transport to be used for the initial fetch. NULL - * means use the transport autodetected from the URL. - * - `remote_callbacks` may be used to specify custom progress callbacks for - * the origin remote before the fetch is initiated. * - `checkout_branch` gives the name of the branch to checkout. NULL means * use the remote's HEAD. */ @@ -62,10 +49,11 @@ typedef struct git_clone_options { unsigned int version; git_checkout_opts checkout_opts; + git_remote_callbacks *remote_callbacks; + int bare; int ignore_cert_errors; - - git_remote_callbacks *remote_callbacks; + const char *remote_name; const char* checkout_branch; } git_clone_options; -- cgit v1.2.1 From 36a241acbb39aa46cf5f7807aebd92e45f2f5eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 20 Sep 2013 23:14:52 +0200 Subject: clone: mention clone_into in the clone documentation Make the difference more explicit. --- include/git2/clone.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index bd602fb7a..a341a413c 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -61,8 +61,11 @@ typedef struct git_clone_options { #define GIT_CLONE_OPTIONS_INIT {GIT_CLONE_OPTIONS_VERSION, {GIT_CHECKOUT_OPTS_VERSION, GIT_CHECKOUT_SAFE_CREATE}} /** - * Clone a remote repository, and checkout the branch pointed to by the remote - * HEAD. + * Clone a remote repository. + * + * This version handles the simple case. If you'd like to create the + * repository or remote with non-default settings, you can create and + * configure them and then use `git_clone_into()`. * * @param out pointer that will receive the resulting repository object * @param url the remote repository to clone -- cgit v1.2.1 From ffc97d51264f8af435ccf52d33a62a6925b174c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Fri, 20 Sep 2013 23:23:42 +0200 Subject: remote: add some comments to the callback struct Hopefully clear up what they're for. --- include/git2/remote.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'include/git2') diff --git a/include/git2/remote.h b/include/git2/remote.h index 8c21870de..8145de180 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -400,15 +400,47 @@ typedef enum git_remote_completion_type { /** * The callback settings structure * - * Set the calbacks to be called by the remote. + * Set the callbacks to be called by the remote when informing the user + * about the progress of the network operations. */ struct git_remote_callbacks { unsigned int version; + /** + * Textual progress from the remote. Text send over the + * progress side-band will be passed to this function (this is + * the 'counting objects' output. + */ void (*progress)(const char *str, int len, void *data); + + /** + * Completion is called when different parts of the download + * process are done (currently unused). + */ int (*completion)(git_remote_completion_type type, void *data); + + /** + * This will be called if the remote host requires + * authentication in order to connect to it. + */ int (*credentials)(git_cred **cred, const char *url, const char *username_from_url, unsigned int allowed_types, void *data); + + /** + * During the download of new data, this will be regularly + * called with the current count of progress done by the + * indexer. + */ int (*transfer_progress)(const git_transfer_progress *stats, void *data); + + /** + * 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); + + /** + * This will be passed to each of the callbacks in this struct + * as the last parameter. + */ void *payload; }; -- cgit v1.2.1 From 0e0cf78773bea0d06298ba3bf981a3be839041df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 2 Oct 2013 14:04:44 +0200 Subject: clone: put the callbacks struct directly in the clone options There's no need for this to be a pointer to somewhere else. --- include/git2/clone.h | 4 ++-- include/git2/remote.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include/git2') diff --git a/include/git2/clone.h b/include/git2/clone.h index a341a413c..331cf92e7 100644 --- a/include/git2/clone.h +++ b/include/git2/clone.h @@ -49,7 +49,7 @@ typedef struct git_clone_options { unsigned int version; git_checkout_opts checkout_opts; - git_remote_callbacks *remote_callbacks; + git_remote_callbacks remote_callbacks; int bare; int ignore_cert_errors; @@ -58,7 +58,7 @@ typedef struct git_clone_options { } git_clone_options; #define GIT_CLONE_OPTIONS_VERSION 1 -#define GIT_CLONE_OPTIONS_INIT {GIT_CLONE_OPTIONS_VERSION, {GIT_CHECKOUT_OPTS_VERSION, GIT_CHECKOUT_SAFE_CREATE}} +#define GIT_CLONE_OPTIONS_INIT {GIT_CLONE_OPTIONS_VERSION, {GIT_CHECKOUT_OPTS_VERSION, GIT_CHECKOUT_SAFE_CREATE}, GIT_REMOTE_CALLBACKS_INIT} /** * Clone a remote repository. diff --git a/include/git2/remote.h b/include/git2/remote.h index 8145de180..9858634cc 100644 --- a/include/git2/remote.h +++ b/include/git2/remote.h @@ -457,7 +457,7 @@ struct git_remote_callbacks { * @param callbacks a pointer to the user's callback settings * @return 0 or an error code */ -GIT_EXTERN(int) git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callbacks); +GIT_EXTERN(int) git_remote_set_callbacks(git_remote *remote, const git_remote_callbacks *callbacks); /** * Get the statistics structure that is filled in by the fetch operation. -- cgit v1.2.1