summaryrefslogtreecommitdiff
path: root/src/clone.c
diff options
context:
space:
mode:
authorPhilip Kelley <phkelley@hotmail.com>2014-06-25 13:20:27 -0400
committerPhilip Kelley <phkelley@hotmail.com>2014-06-26 22:34:37 -0400
commit1697cd6ff5d29c95106ff4b7bd56ebba5d51b8c1 (patch)
tree05e0f995c3782e0dd9b220b0fcc8ad09fc8dd96f /src/clone.c
parent86cb34cb110c6a1ec6e1d1525418c70f2f617d6b (diff)
downloadlibgit2-1697cd6ff5d29c95106ff4b7bd56ebba5d51b8c1.tar.gz
Improvements to git_transport extensibility
git_remote_set_transport now takes a transport factory rather than a transport git_clone_options now allows the caller to specify a remote creation callback
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/clone.c b/src/clone.c
index 6c4fb6727..a4ed1a29c 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -229,6 +229,22 @@ cleanup:
return retcode;
}
+static int default_remote_create(
+ git_remote **out,
+ git_repository *repo,
+ const char *name,
+ const char *url,
+ void *payload)
+{
+ int error;
+ git_remote_callbacks *callbacks = payload;
+
+ if ((error = git_remote_create(out, repo, name, url)) < 0)
+ return error;
+
+ return git_remote_set_callbacks(*out, callbacks);
+}
+
/*
* submodules?
*/
@@ -241,8 +257,9 @@ static int create_and_configure_origin(
{
int error;
git_remote *origin = NULL;
- const char *name;
char buf[GIT_PATH_MAX];
+ git_remote_create_cb remote_create = options->remote_cb;
+ void *payload = options->remote_cb_payload;
/* If the path exists and is a dir, the url should be the absolute path */
if (git_path_root(url) < 0 && git_path_exists(url) && git_path_isdir(url)) {
@@ -252,14 +269,12 @@ static int create_and_configure_origin(
url = buf;
}
- name = options->remote_name ? options->remote_name : "origin";
- if ((error = git_remote_create(&origin, repo, name, url)) < 0)
- goto on_error;
-
- if (options->ignore_cert_errors)
- git_remote_check_cert(origin, 0);
+ if (!remote_create) {
+ remote_create = default_remote_create;
+ payload = (void *)&options->remote_callbacks;
+ }
- if ((error = git_remote_set_callbacks(origin, &options->remote_callbacks)) < 0)
+ if ((error = remote_create(&origin, repo, "origin", url, payload)) < 0)
goto on_error;
if ((error = git_remote_save(origin)) < 0)